summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKnud Dollereder <knud.dollereder@qt.io>2021-06-09 16:00:51 +0200
committerKnud Dollereder <knud.dollereder@qt.io>2021-06-09 20:02:44 +0000
commit0a497287270d479d7fde5109b2b51683b590c8b2 (patch)
tree2cc8d1418468241cbce9bcaa6dbd413f04a12f5f
parent4c699d518110554f9ca3ff4ab1ad09dc4c089fc1 (diff)
downloadqt-creator-0a497287270d479d7fde5109b2b51683b590c8b2.tar.gz
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>
-rw-r--r--src/libs/advanceddockingsystem/dockmanager.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/libs/advanceddockingsystem/dockmanager.cpp b/src/libs/advanceddockingsystem/dockmanager.cpp
index 7ae018b912..5301e08c0b 100644
--- a/src/libs/advanceddockingsystem/dockmanager.cpp
+++ b/src/libs/advanceddockingsystem/dockmanager.cpp
@@ -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;
}