An exception is raised on the line with delete widget. glibc complains:
free(): invalid pointer: 0xbe80291c
void MyServer::clearMyLayout(void)
{
QLayout *currentLayout
= window
->layout
();
if (currentLayout != NULL)
{
while ((item= currentLayout->takeAt(0)) != 0)
{
if ((widget = item->widget()) != 0)
delete widget; // SigAbort happens here
delete item;
}
}
delete window->layout();
}
void MyServer::clearMyLayout(void)
{
QLayout *currentLayout = window->layout();
if (currentLayout != NULL)
{
QLayoutItem* item;
while ((item= currentLayout->takeAt(0)) != 0)
{
QWidget *widget;
if ((widget = item->widget()) != 0)
delete widget; // SigAbort happens here
delete item;
}
}
delete window->layout();
}
To copy to clipboard, switch view to plain text mode
I'm trying to remove all the widgets in a QHBoxLayout. I read that you must delete the widgets and if only delete the item, the widgets are still visible in the parent widget. I found that code fragment along with discussions about the parent being the widget, no the layout.
But shouldn't I be able to delete any non-zero pointer returned by QLayoutItem->widget()?
Thanks,
Dave Thomas
Added after 1 32 minutes:
One of the widgets in the layout was a private data member of an object--not a pointer.
That eliminates the exception--hoping it now works.
Bookmarks