From 6504c42e755c908f92cad6dd05aef53344a0b9d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fauconnier?= Date: Fri, 12 Nov 2021 15:56:41 +0100 Subject: [PATCH] fixed an issue where mSelectedThumbnail could become inconsistent + fixed an issue where a blank page would be added while importing the same document again and again --- src/core/UBPersistenceManager.cpp | 5 ++++- src/document/UBDocumentContainer.cpp | 1 - src/document/UBDocumentController.cpp | 13 ++++++++----- src/gui/UBDocumentNavigator.cpp | 4 +++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 0642f63d..ae4c2180 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -238,7 +238,10 @@ QDialog::DialogCode UBPersistenceManager::processInteractiveReplacementDialog(UB if (mDocumentTreeStructureModel->currentIndex() == replaceIndex) { - UBApplication::documentController->selectDocument(pProxy, true, true); + if (pProxy->pageCount() > 0) + { + UBApplication::documentController->selectDocument(pProxy, true, true); + } } if (replaceProxy) { diff --git a/src/document/UBDocumentContainer.cpp b/src/document/UBDocumentContainer.cpp index 2609158b..445b1304 100644 --- a/src/document/UBDocumentContainer.cpp +++ b/src/document/UBDocumentContainer.cpp @@ -49,7 +49,6 @@ void UBDocumentContainer::setDocument(UBDocumentProxy* document, bool forceReloa { mCurrentDocument = document; - //qDebug() << documentThumbs(); clearThumbPage(); reloadThumbnails(); emit documentSet(mCurrentDocument); diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index 3f5791d0..6166f806 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -1854,12 +1854,15 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr if (setAsCurrentDocument) { UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel->setCurrentDocument(proxy); QModelIndex indexCurrentDoc = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel->indexForProxy(proxy); - mDocumentUI->documentTreeView->setSelectedAndExpanded(indexCurrentDoc, true, editMode); - - if (proxy != mBoardController->selectedDocument()) // only if wanted Document is different from document actually on Board, // ALTI/AOU - 20140217 + if (indexCurrentDoc.isValid()) { - //issue 1629 - NNE - 20131105 : When set a current document, change in the board controller - mBoardController->setActiveDocumentScene(proxy, 0, true, onImport); + mDocumentUI->documentTreeView->setSelectedAndExpanded(indexCurrentDoc, true, editMode); + + if (proxy != mBoardController->selectedDocument()) // only if wanted Document is different from document actually on Board, // ALTI/AOU - 20140217 + { + //issue 1629 - NNE - 20131105 : When set a current document, change in the board controller + mBoardController->setActiveDocumentScene(proxy, 0, true, onImport); + } } } diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index 7d045b3a..4f0adba3 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -224,6 +224,8 @@ void UBDocumentNavigator::updateSpecificThumbnail(int iPage) mThumbsWithLabels[iPage].setThumbnail(newItem); if (mLastClickedThumbnail == oldItem) mLastClickedThumbnail = newItem; + if (mSelectedThumbnail == oldItem) + mSelectedThumbnail = newItem; delete oldItem; oldItem = NULL; } @@ -317,7 +319,7 @@ void UBDocumentNavigator::resizeEvent(QResizeEvent *event) mThumbnailWidth = (width() > mThumbnailMinWidth) ? width() - 2*border() : mThumbnailMinWidth; if(mSelectedThumbnail) - ensureVisible(mSelectedThumbnail); + ensureVisible(mSelectedThumbnail); // Refresh the scene refreshScene();