duplication fixed. Crash on closing the application after creating a new document fixed.

preferencesAboutTextFull
Claudio Valerio 11 years ago
parent 98e4abb7b4
commit 39a1284023
  1. 12
      src/board/UBBoardController.cpp
  2. 2
      src/board/UBBoardController.h
  3. 19
      src/core/UBPersistenceManager.cpp
  4. 2
      src/core/UBPersistenceManager.h

@ -481,7 +481,7 @@ void UBBoardController::stylusToolDoubleClicked(int tool)
void UBBoardController::addScene() void UBBoardController::addScene()
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
persistCurrentScene(); persistCurrentScene(false,true);
UBDocumentContainer::addPage(mActiveSceneIndex + 1); UBDocumentContainer::addPage(mActiveSceneIndex + 1);
@ -523,7 +523,7 @@ void UBBoardController::addScene(UBGraphicsScene* scene, bool replaceActiveIfEmp
} }
else else
{ {
persistCurrentScene(); persistCurrentScene(false,true);
UBPersistenceManager::persistenceManager()->insertDocumentSceneAt(selectedDocument(), clone, mActiveSceneIndex + 1); UBPersistenceManager::persistenceManager()->insertDocumentSceneAt(selectedDocument(), clone, mActiveSceneIndex + 1);
setActiveDocumentScene(mActiveSceneIndex + 1); setActiveDocumentScene(mActiveSceneIndex + 1);
} }
@ -546,7 +546,7 @@ void UBBoardController::addScene(UBDocumentProxy* proxy, int sceneIndex, bool re
void UBBoardController::duplicateScene(int nIndex) void UBBoardController::duplicateScene(int nIndex)
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
persistCurrentScene(); persistCurrentScene(false,true);
QList<int> scIndexes; QList<int> scIndexes;
scIndexes << nIndex; scIndexes << nIndex;
@ -1538,7 +1538,7 @@ void UBBoardController::moveSceneToIndex(int source, int target)
if (selectedDocument()) if (selectedDocument())
{ {
persistCurrentScene(); persistCurrentScene(false,true);
UBDocumentContainer::movePageToIndex(source, target); UBDocumentContainer::movePageToIndex(source, target);
@ -1890,14 +1890,14 @@ void UBBoardController::show()
UBApplication::mainWindow->actionLibrary->setChecked(false); UBApplication::mainWindow->actionLibrary->setChecked(false);
} }
void UBBoardController::persistCurrentScene(bool isAnAutomaticBackup) void UBBoardController::persistCurrentScene(bool isAnAutomaticBackup, bool forceImmediateSave)
{ {
if(UBPersistenceManager::persistenceManager() if(UBPersistenceManager::persistenceManager()
&& selectedDocument() && mActiveScene && mActiveSceneIndex != mDeletingSceneIndex && selectedDocument() && mActiveScene && mActiveSceneIndex != mDeletingSceneIndex
&& (mActiveSceneIndex >= 0) && mActiveSceneIndex != mMovingSceneIndex && (mActiveSceneIndex >= 0) && mActiveSceneIndex != mMovingSceneIndex
&& (mActiveScene->isModified())) && (mActiveScene->isModified()))
{ {
UBPersistenceManager::persistenceManager()->persistDocumentScene(selectedDocument(), mActiveScene, mActiveSceneIndex, isAnAutomaticBackup); UBPersistenceManager::persistenceManager()->persistDocumentScene(selectedDocument(), mActiveScene, mActiveSceneIndex, isAnAutomaticBackup,forceImmediateSave);
updatePage(mActiveSceneIndex); updatePage(mActiveSceneIndex);
} }
} }

@ -156,7 +156,7 @@ class UBBoardController : public UBDocumentContainer
return mSystemScaleFactor; return mSystemScaleFactor;
} }
qreal currentZoom(); qreal currentZoom();
void persistCurrentScene(bool isAnAutomaticBackup = false); void persistCurrentScene(bool isAnAutomaticBackup = false, bool forceImmediateSave = false);
void showNewVersionAvailable(bool automatic, const UBVersion &installedVersion, const UBSoftwareUpdate &softwareUpdate); void showNewVersionAvailable(bool automatic, const UBVersion &installedVersion, const UBSoftwareUpdate &softwareUpdate);
void setBoxing(QRect displayRect); void setBoxing(QRect displayRect);
void setToolbarTexts(); void setToolbarTexts();

@ -725,7 +725,7 @@ UBGraphicsScene* UBPersistenceManager::loadDocumentScene(UBDocumentProxy* proxy,
return scene; return scene;
} }
void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* pScene, const int pSceneIndex, bool isAnAutomaticBackup) void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* pScene, const int pSceneIndex, bool isAnAutomaticBackup, bool forceImmediateSaving)
{ {
checkIfDocumentRepositoryExists(); checkIfDocumentRepositoryExists();
@ -745,12 +745,13 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
if (pScene->isModified()) if (pScene->isModified())
{ {
UBThumbnailAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex); UBThumbnailAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex);
QTime time; if(forceImmediateSaving)
time.start(); UBSvgSubsetAdaptor::persistScene(pDocumentProxy,pScene,pSceneIndex);
UBGraphicsScene* copiedScene = pScene->sceneDeepCopy(); else{
qDebug() << "time to duplicate scene " << time.elapsed() << " ms"; UBGraphicsScene* copiedScene = pScene->sceneDeepCopy();
mWorker->saveScene(pDocumentProxy, copiedScene, pSceneIndex); mWorker->saveScene(pDocumentProxy, copiedScene, pSceneIndex);
pScene->setModified(false); pScene->setModified(false);
}
} }
} }
@ -909,8 +910,10 @@ bool UBPersistenceManager::isEmpty(UBDocumentProxy* pDocumentProxy)
if (theSoleScene) if (theSoleScene)
{ {
empty = theSoleScene->isEmpty(); empty = theSoleScene->isEmpty();
if(empty) if(empty){
mSceneCache.removeScene(pDocumentProxy,0);
delete theSoleScene; delete theSoleScene;
}
} }
else else
{ {

@ -75,7 +75,7 @@ class UBPersistenceManager : public QObject
virtual void duplicateDocumentScene(UBDocumentProxy* pDocumentProxy, int index); virtual void duplicateDocumentScene(UBDocumentProxy* pDocumentProxy, int index);
virtual void persistDocumentScene(UBDocumentProxy* pDocumentProxy, virtual void persistDocumentScene(UBDocumentProxy* pDocumentProxy,
UBGraphicsScene* pScene, const int pSceneIndex, bool isAnAutomaticBackup = false); UBGraphicsScene* pScene, const int pSceneIndex, bool isAnAutomaticBackup = false, bool forceImmediateSaving = false);
virtual UBGraphicsScene* createDocumentSceneAt(UBDocumentProxy* pDocumentProxy, int index, bool useUndoRedoStack = true); virtual UBGraphicsScene* createDocumentSceneAt(UBDocumentProxy* pDocumentProxy, int index, bool useUndoRedoStack = true);

Loading…
Cancel
Save