From 694123c3448c4ae90f976b781f217845d80b307c Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Sat, 11 Feb 2017 18:54:54 -0500 Subject: [PATCH] Fix for crash when exiting with an empty document This removes a few instances of deleting a scene twice, or accessing elements of a scene after they've been deleted. Previously, the application would crash upon exiting if the scene was empty but had been modified (e.g if an object was placed on the board then deleted, then the application closed) --- src/core/UBApplicationController.cpp | 1 - src/core/UBPersistenceManager.cpp | 11 +++++++---- src/core/UBPersistenceManager.h | 2 ++ src/desktop/UBDesktopAnnotationController.cpp | 5 ++++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index 04b49ed6..36ae40ca 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -658,7 +658,6 @@ void UBApplicationController::closing() if (mUninoteController) { - mUninoteController->hideWindow(); mUninoteController->close(); } diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 280acfea..d5de377b 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -67,6 +67,7 @@ UBPersistenceManager * UBPersistenceManager::sSingleton = 0; UBPersistenceManager::UBPersistenceManager(QObject *pParent) : QObject(pParent) , mHasPurgedDocuments(false) + , mIsApplicationClosing(false) , mIsWorkerFinished(false) { @@ -131,8 +132,10 @@ void UBPersistenceManager::destroy() void UBPersistenceManager::onScenePersisted(UBGraphicsScene* scene) { - delete scene; - scene = NULL; + if (!mIsApplicationClosing) { + delete scene; + scene = NULL; + } } void UBPersistenceManager::onMetadataPersisted(UBDocumentProxy* proxy) @@ -147,6 +150,8 @@ void UBPersistenceManager::onWorkerFinished() UBPersistenceManager::~UBPersistenceManager() { + mIsApplicationClosing = true; + if(mWorker) mWorker->applicationWillClose(); @@ -943,7 +948,6 @@ bool UBPersistenceManager::isEmpty(UBDocumentProxy* pDocumentProxy) empty = theSoleScene->isEmpty(); if(empty){ mSceneCache.removeScene(pDocumentProxy,0); - delete theSoleScene; theSoleScene = NULL; } else{ @@ -960,7 +964,6 @@ bool UBPersistenceManager::isEmpty(UBDocumentProxy* pDocumentProxy) } if(!usefulItemFound){ mSceneCache.removeScene(pDocumentProxy,0); - delete theSoleScene; theSoleScene = NULL; empty = true; } diff --git a/src/core/UBPersistenceManager.h b/src/core/UBPersistenceManager.h index 08556061..19d10f66 100644 --- a/src/core/UBPersistenceManager.h +++ b/src/core/UBPersistenceManager.h @@ -157,6 +157,8 @@ class UBPersistenceManager : public QObject QThread* mThread; bool mIsWorkerFinished; + bool mIsApplicationClosing; + private slots: void documentRepositoryChanged(const QString& path); void errorString(QString error); diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp index 3544d464..f17911be 100644 --- a/src/desktop/UBDesktopAnnotationController.cpp +++ b/src/desktop/UBDesktopAnnotationController.cpp @@ -354,7 +354,10 @@ void UBDesktopAnnotationController::showWindow() void UBDesktopAnnotationController::close() { - // NOOP + if (mTransparentDrawingView) + mTransparentDrawingView->hide(); + + mDesktopPalette->hide(); }