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