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

@ -156,7 +156,7 @@ class UBBoardController : public UBDocumentContainer
return mSystemScaleFactor;
}
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 setBoxing(QRect displayRect);
void setToolbarTexts();

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

@ -75,7 +75,7 @@ class UBPersistenceManager : public QObject
virtual void duplicateDocumentScene(UBDocumentProxy* pDocumentProxy, int index);
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);

Loading…
Cancel
Save