PDA

View Full Version : There seams to be a memoryleak in Border Layout Example



FSDrake
27th September 2016, 13:52
Hi,

there seams to be a memoryleak in Border Layout Example. The class BorderLayout holds a list of pointers to ItemWrapper. The ItemWrapper itself will not deleted in the deconstructor of BorderLayout. Followed my fixed version:

BorderLayout::~BorderLayout()
{
QLayoutItem *l; ItemWrapper*w;
for (int i = 0; i < list.count(); i++)
{
w = (ItemWrapper*)list.at(i);
delete w->item;
delete w;
}
list.clear();
// while ((l = takeAt(0)))
// delete l;
}