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)
preferencesAboutTextFull
Craig Watson 8 years ago
parent 14849cf538
commit 694123c344
  1. 1
      src/core/UBApplicationController.cpp
  2. 11
      src/core/UBPersistenceManager.cpp
  3. 2
      src/core/UBPersistenceManager.h
  4. 5
      src/desktop/UBDesktopAnnotationController.cpp

@ -658,7 +658,6 @@ void UBApplicationController::closing()
if (mUninoteController) if (mUninoteController)
{ {
mUninoteController->hideWindow();
mUninoteController->close(); mUninoteController->close();
} }

@ -67,6 +67,7 @@ UBPersistenceManager * UBPersistenceManager::sSingleton = 0;
UBPersistenceManager::UBPersistenceManager(QObject *pParent) UBPersistenceManager::UBPersistenceManager(QObject *pParent)
: QObject(pParent) : QObject(pParent)
, mHasPurgedDocuments(false) , mHasPurgedDocuments(false)
, mIsApplicationClosing(false)
, mIsWorkerFinished(false) , mIsWorkerFinished(false)
{ {
@ -131,8 +132,10 @@ void UBPersistenceManager::destroy()
void UBPersistenceManager::onScenePersisted(UBGraphicsScene* scene) void UBPersistenceManager::onScenePersisted(UBGraphicsScene* scene)
{ {
delete scene; if (!mIsApplicationClosing) {
scene = NULL; delete scene;
scene = NULL;
}
} }
void UBPersistenceManager::onMetadataPersisted(UBDocumentProxy* proxy) void UBPersistenceManager::onMetadataPersisted(UBDocumentProxy* proxy)
@ -147,6 +150,8 @@ void UBPersistenceManager::onWorkerFinished()
UBPersistenceManager::~UBPersistenceManager() UBPersistenceManager::~UBPersistenceManager()
{ {
mIsApplicationClosing = true;
if(mWorker) if(mWorker)
mWorker->applicationWillClose(); mWorker->applicationWillClose();
@ -943,7 +948,6 @@ bool UBPersistenceManager::isEmpty(UBDocumentProxy* pDocumentProxy)
empty = theSoleScene->isEmpty(); empty = theSoleScene->isEmpty();
if(empty){ if(empty){
mSceneCache.removeScene(pDocumentProxy,0); mSceneCache.removeScene(pDocumentProxy,0);
delete theSoleScene;
theSoleScene = NULL; theSoleScene = NULL;
} }
else{ else{
@ -960,7 +964,6 @@ bool UBPersistenceManager::isEmpty(UBDocumentProxy* pDocumentProxy)
} }
if(!usefulItemFound){ if(!usefulItemFound){
mSceneCache.removeScene(pDocumentProxy,0); mSceneCache.removeScene(pDocumentProxy,0);
delete theSoleScene;
theSoleScene = NULL; theSoleScene = NULL;
empty = true; empty = true;
} }

@ -157,6 +157,8 @@ class UBPersistenceManager : public QObject
QThread* mThread; QThread* mThread;
bool mIsWorkerFinished; bool mIsWorkerFinished;
bool mIsApplicationClosing;
private slots: private slots:
void documentRepositoryChanged(const QString& path); void documentRepositoryChanged(const QString& path);
void errorString(QString error); void errorString(QString error);

@ -354,7 +354,10 @@ void UBDesktopAnnotationController::showWindow()
void UBDesktopAnnotationController::close() void UBDesktopAnnotationController::close()
{ {
// NOOP if (mTransparentDrawingView)
mTransparentDrawingView->hide();
mDesktopPalette->hide();
} }

Loading…
Cancel
Save