Fix for losing content mentioned in the ticket 228. The problem was actually in page deletion algorithm which has been flooding cache with invalid data, and that data was a object to return when loadDocumentScene was called.

preferencesAboutTextFull
Anatoly Mihalchenko 13 years ago
parent 0d2565c25d
commit 71d9a71a26
  1. 20
      src/core/UBPersistenceManager.cpp
  2. 2
      src/core/UBPersistenceManager.h

@ -240,7 +240,7 @@ QStringList UBPersistenceManager::allWidgets(const QDir& dir)
}
UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName, const QString& pName)
UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName, const QString& pName, bool withEmptyPage)
{
checkIfDocumentRepositoryExists();
@ -259,7 +259,7 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName,
doc->setMetaData(UBSettings::documentVersion, UBSettings::currentFileVersion);
doc->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
createDocumentSceneAt(doc, 0);
if (withEmptyPage) createDocumentSceneAt(doc, 0);
documentProxies.insert(0, QPointer<UBDocumentProxy>(doc));
@ -397,15 +397,14 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL
QString sourceGroupName = proxy->metaData(UBSettings::documentGroupName).toString();
QString sourceName = proxy->metaData(UBSettings::documentName).toString();
UBDocumentProxy *trashDocProxy = createDocument(UBSettings::trashedDocumentGroupNamePrefix + sourceGroupName, sourceName);
UBDocumentProxy *trashDocProxy = createDocument(UBSettings::trashedDocumentGroupNamePrefix + sourceGroupName, sourceName, false);
foreach(int index, compactedIndexes)
{
UBGraphicsScene *scene = loadDocumentScene(proxy, index);
if (scene)
{
UBGraphicsScene* sceneClone = scene->sceneDeepCopy();
//scene is about to move into new document
foreach (QUrl relativeFile, scene->relativeDependencies())
{
QString source = scene->document()->persistencePath() + "/" + relativeFile.toString();
@ -418,19 +417,10 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL
QFile::copy(source, target);
}
insertDocumentSceneAt(trashDocProxy, sceneClone, trashDocProxy->pageCount());
insertDocumentSceneAt(trashDocProxy, scene, trashDocProxy->pageCount());
}
}
// Delete empty first page
QString svgFileName = trashDocProxy->persistencePath() +
UBFileSystemUtils::digitFileFormat("/page%1.svg", 1);
QFile::remove(svgFileName);
QString thumbFileName = trashDocProxy->persistencePath() +
UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", 1);
QFile::remove(thumbFileName);
trashDocProxy->decPageCount();
for (int i = 1; i < pageCount; i++)
{
renamePage(trashDocProxy, i , i - 1);

@ -60,7 +60,7 @@ class UBPersistenceManager : public QObject
static UBPersistenceManager* persistenceManager();
static void destroy();
virtual UBDocumentProxy* createDocument(const QString& pGroupName = "", const QString& pName = "");
virtual UBDocumentProxy* createDocument(const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = true);
virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory);
virtual UBDocumentProxy* persistDocumentMetadata(UBDocumentProxy* pDocumentProxy);

Loading…
Cancel
Save