Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Fix crash when closing Krita before the document is fully loaded
Dmitry Kazakovceec98e40d12
diff --git a/libs/ui/KisMainWindow.cpp b/libs/ui/KisMainWindow.cppindex 7875fb45bc..260851f1ee 100644--- a/libs/ui/KisMainWindow.cpp+++ b/libs/ui/KisMainWindow.cpp@@ -712,6 +712,22 @@ KisMainWindow::~KisMainWindow()// }// }+ /**+ * Detructor of KisView accesses KisViewManager is multiple ways,+ * directly and via KoToolManager. Hence we should destroy all the+ * subwindows **before** we actually destroy the view manager.+ *+ * Please note that we cannot just `close()` the subwindows, becasue+ * they are deleted with deleteLater(), which may postpone their+ * destruction till after KisViewManager's death.+ */+ Q_FOREACH (QMdiSubWindow *subwin, d->mdiArea->subWindowList()) {+ if (subwin) {+ (void) subwin->close();+ delete subwin;+ }+ }+// The doc and view might still exist (this is the case when closing the window)KisPart::instance()->removeMainWindow(this);diff --git a/libs/ui/KisView.cpp b/libs/ui/KisView.cppindex 08f964f93c..cfc89bb9cd 100644--- a/libs/ui/KisView.cpp+++ b/libs/ui/KisView.cpp@@ -126,7 +126,7 @@ public:KisCanvasController canvasController;KisCanvas2 canvas;KisZoomManager zoomManager;- KisViewManager *viewManager {nullptr};+ QPointer<KisViewManager> viewManager;KisNodeSP currentNode;KisPaintingAssistantsDecorationSP paintingAssistantsDecoration;KisReferenceImagesDecorationSP referenceImagesDecoration;