|
|
@ -65,6 +65,7 @@ UBPersistenceManager * UBPersistenceManager::sSingleton = 0; |
|
|
|
UBPersistenceManager::UBPersistenceManager(QObject *pParent) |
|
|
|
UBPersistenceManager::UBPersistenceManager(QObject *pParent) |
|
|
|
: QObject(pParent) |
|
|
|
: QObject(pParent) |
|
|
|
, mHasPurgedDocuments(false) |
|
|
|
, mHasPurgedDocuments(false) |
|
|
|
|
|
|
|
, mIsWorkerFinished(false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
mDocumentSubDirectories << imageDirectory; |
|
|
|
mDocumentSubDirectories << imageDirectory; |
|
|
@ -81,6 +82,7 @@ UBPersistenceManager::UBPersistenceManager(QObject *pParent) |
|
|
|
connect(mWorker, SIGNAL(error(QString)), this, SLOT(errorString(QString))); |
|
|
|
connect(mWorker, SIGNAL(error(QString)), this, SLOT(errorString(QString))); |
|
|
|
connect(mThread, SIGNAL(started()), mWorker, SLOT(process())); |
|
|
|
connect(mThread, SIGNAL(started()), mWorker, SLOT(process())); |
|
|
|
connect(mWorker, SIGNAL(finished()), mThread, SLOT(quit())); |
|
|
|
connect(mWorker, SIGNAL(finished()), mThread, SLOT(quit())); |
|
|
|
|
|
|
|
connect(mWorker, SIGNAL(finished()), this, SLOT(onWorkerFinished())); |
|
|
|
connect(mWorker, SIGNAL(finished()), mWorker, SLOT(deleteLater())); |
|
|
|
connect(mWorker, SIGNAL(finished()), mWorker, SLOT(deleteLater())); |
|
|
|
connect(mThread, SIGNAL(finished()), mThread, SLOT(deleteLater())); |
|
|
|
connect(mThread, SIGNAL(finished()), mThread, SLOT(deleteLater())); |
|
|
|
connect(mWorker,SIGNAL(sceneLoaded(QByteArray,UBDocumentProxy*,int)),this,SLOT(onSceneLoaded(QByteArray,UBDocumentProxy*,int))); |
|
|
|
connect(mWorker,SIGNAL(sceneLoaded(QByteArray,UBDocumentProxy*,int)),this,SLOT(onSceneLoaded(QByteArray,UBDocumentProxy*,int))); |
|
|
@ -105,11 +107,24 @@ void UBPersistenceManager::destroy() |
|
|
|
sSingleton = NULL; |
|
|
|
sSingleton = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBPersistenceManager::onWorkerFinished() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mIsWorkerFinished = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBPersistenceManager::~UBPersistenceManager() |
|
|
|
UBPersistenceManager::~UBPersistenceManager() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(mWorker) |
|
|
|
if(mWorker) |
|
|
|
mWorker->applicationWillClose(); |
|
|
|
mWorker->applicationWillClose(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QTime time; |
|
|
|
|
|
|
|
time.start(); |
|
|
|
|
|
|
|
qDebug() << "start waiting"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(!mIsWorkerFinished) |
|
|
|
|
|
|
|
QCoreApplication::processEvents(QEventLoop::AllEvents, 100); |
|
|
|
|
|
|
|
qDebug() << "stop waiting after " << time.elapsed() << " ms"; |
|
|
|
|
|
|
|
|
|
|
|
foreach(QPointer<UBDocumentProxy> proxyGuard, documentProxies) |
|
|
|
foreach(QPointer<UBDocumentProxy> proxyGuard, documentProxies) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!proxyGuard.isNull()) |
|
|
|
if (!proxyGuard.isNull()) |
|
|
@ -117,7 +132,6 @@ UBPersistenceManager::~UBPersistenceManager() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// to be sure that all the scenes are stored on disk
|
|
|
|
// to be sure that all the scenes are stored on disk
|
|
|
|
mThread->wait(10*1000); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBPersistenceManager::errorString(QString error) |
|
|
|
void UBPersistenceManager::errorString(QString error) |
|
|
|