summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2016-11-18 14:30:19 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2016-11-18 14:10:34 +0000
commitd743e5a7583f242142bcab3ce927490228c5df29 (patch)
tree548fcaa584779ba88122dc63211b04ea9250346d
parentee43dae6c9e2c0ba12eca597446d1fa5b58d603f (diff)
Fix a crash on Designer exit
After the destructor of FormWindow itself has finished, it starts destructing its fields. One of them is an undo stack. Unfortunately, the destructor of QUndoStack emits signals. One of its signals is being received in QDesignerFormWindow::updateChanged(). The QDesignerFormWindow keeps a QPointer<FormWindow> m_editor which we are currently destructing. The destructor of FormWindow finished, but the destructor of its base QObject didn't run yet, so all QPointer instances pointing to it are not nulled yet. Inside the updateChanged() we ensure that m_editor is still alive, however this check is wrong in Qt5 times. The QPointer will be nulled when the destructor of base QObject finishes, so we read that m_editor is valid, while it is in the middle of destruction. Then we call some method on it which leads to the crash. The current fix disconnects the undo stack's signals prior to destuction. It also removes the undo stack from the undo group. Task-number: QTBUG-57201 Change-Id: I753b5c8cae2b630d7cdec13b0dfe325d16726e82 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--src/designer/src/components/formeditor/formwindow.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/designer/src/components/formeditor/formwindow.cpp b/src/designer/src/components/formeditor/formwindow.cpp
index 162f5d0e3..77e96c307 100644
--- a/src/designer/src/components/formeditor/formwindow.cpp
+++ b/src/designer/src/components/formeditor/formwindow.cpp
@@ -329,6 +329,10 @@ FormWindow::~FormWindow()
if (resourceSet())
core()->resourceModel()->removeResourceSet(resourceSet());
delete m_selection;
+
+ if (FormWindowManager *manager = qobject_cast<FormWindowManager*> (core()->formWindowManager()))
+ manager->undoGroup()->removeStack(&m_undoStack);
+ m_undoStack.disconnect();
}
QDesignerFormEditorInterface *FormWindow::core() const