Commit 694123c3 authored by Craig Watson's avatar Craig Watson

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)
parent 14849cf5
......@@ -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();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment