Skip to content

Commit fb6e538

Browse files
committed
fix : call sceneCount (which is not cost free in a network-storage context) only once, at start, then only manipulate pageCount.
1 parent ece619d commit fb6e538

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/core/UBPersistenceManager.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ std::shared_ptr<UBDocumentProxy> UBPersistenceManager::duplicateDocument(std::sh
756756

757757
persistDocumentMetadata(copy);
758758

759-
copy->setPageCount(sceneCount(copy));
759+
copy->setPageCount(copy->pageCount());
760760

761761
emit documentCreated(copy);
762762

@@ -769,7 +769,7 @@ void UBPersistenceManager::deleteDocumentScenes(std::shared_ptr<UBDocumentProxy>
769769
{
770770
checkIfDocumentRepositoryExists();
771771

772-
int pageCount = UBPersistenceManager::persistenceManager()->sceneCount(proxy);
772+
int pageCount = proxy->pageCount();
773773

774774
QList<int> compactedIndexes;
775775

@@ -858,9 +858,7 @@ void UBPersistenceManager::duplicateDocumentScene(std::shared_ptr<UBDocumentProx
858858
{
859859
checkIfDocumentRepositoryExists();
860860

861-
int pageCount = UBPersistenceManager::persistenceManager()->sceneCount(proxy);
862-
863-
for (int i = pageCount; i > index + 1; i--)
861+
for (int i = proxy->pageCount(); i > index + 1; i--)
864862
{
865863
renamePage(proxy, i - 1 , i);
866864

@@ -1023,7 +1021,7 @@ void UBPersistenceManager::insertDocumentSceneAt(std::shared_ptr<UBDocumentProxy
10231021
{
10241022
scene->setDocument(proxy);
10251023

1026-
int count = sceneCount(proxy);
1024+
int count = proxy->pageCount();
10271025

10281026
for(int i = count - 1; i >= index; i--)
10291027
{
@@ -1284,7 +1282,7 @@ bool UBPersistenceManager::addDirectoryContentToDocument(const QString& document
12841282
return false;
12851283
}
12861284

1287-
pDocument->setPageCount(sceneCount(pDocument));
1285+
pDocument->setPageCount(pDocument->pageCount());
12881286

12891287
//issue NC - NNE - 20131213 : At this point, all is well done.
12901288
return true;

0 commit comments

Comments
 (0)