forked from qt-creator/qt-creator
Fix a crash-on-close in the dockmanager
The destructor of DockManager deletes floatingwidgets in a for loop. The destructor of these floatingWidgets calls back to the DockManager and alters the list it is currently iterating over. This is now quick-fixed by deferring the deletion by using a temporal vector. Change-Id: I40b77ea505a5fc7506117dc16476e2e498ce4aef Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -357,13 +357,20 @@ namespace ADS
|
||||
save();
|
||||
saveStartupWorkspace();
|
||||
|
||||
// Using a temporal vector since the destructor of
|
||||
// FloatingDockWidgetContainer alters d->m_floatingWidgets.
|
||||
std::vector<FloatingDockContainer *> aboutToDeletes;
|
||||
for (auto floatingWidget : qAsConst(d->m_floatingWidgets)) {
|
||||
/* There have been crashes with partially destructed widgets in
|
||||
m_floatingWidgets. Those do not have a parent. */
|
||||
if (floatingWidget && floatingWidget->parent() == this)
|
||||
delete floatingWidget.data();
|
||||
if (floatingWidget)
|
||||
aboutToDeletes.push_back(floatingWidget);
|
||||
}
|
||||
|
||||
for (auto del : aboutToDeletes) {
|
||||
delete del;
|
||||
}
|
||||
|
||||
d->m_floatingWidgets.clear();
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user