Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
6.2.4
-
None
-
Windows 11
Description
I have written a code with a QApplication creating the QMainWindow. In this scheme, the QMainWindow is, by default, not on mode DeleteOnClose.
In the destructor of QApplication, there is the following loop:
for (QWidgetSet::ConstIterator it = mySet->constBegin(), cend = mySet->constEnd(); it != cend; ++it) { QWidget *w = *it; if (!w->parent()) // window w->destroy(true, true); }
So, when w is the QMainWindow, destroy() is called. And all the children of QMainWindow are deleted. Then, the list mySet contains inconsistencies. Because all widgets of the MainWindow are still present, but deleted. So, when the test (!w->parent()) occurs on a deleted QWidget, a crash occurs (in debug mode).
For the MainWindow, the option is to add WA_DeleteOnClose to avoid this problem. But it is possible for other QWidget not having parent, and having children.