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)
{
mUninoteController->hideWindow();
mUninoteController->close();
}

@ -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;
}

@ -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);

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

Loading…
Cancel
Save