From b3692061a57ae7d434b87cb190f0b18a1e0d32c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fauconnier?= Date: Thu, 10 Jun 2021 16:53:04 +0200 Subject: [PATCH] fixed an issue where erase a stroke then clear the scene before changing page would cause a crash --- src/board/UBBoardController.cpp | 22 ++++++++++++++++------ src/board/UBBoardController.h | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index a836e3bc..62dcd073 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -1632,11 +1632,11 @@ void UBBoardController::moveSceneToIndex(int source, int target) } } -void UBBoardController::findUniquesItems(const QUndoCommand *parent, QSet &itms) +void UBBoardController::findUniquesItems(const QUndoCommand *parent, QSet &items) { if (parent->childCount()) { for (int i = 0; i < parent->childCount(); i++) { - findUniquesItems(parent->child(i), itms); + findUniquesItems(parent->child(i), items); } } @@ -1657,16 +1657,26 @@ void UBBoardController::findUniquesItems(const QUndoCommand *parent, QSetparentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type())) - itms.insert(item); + if (!items.contains(item) && + !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()) && + !items.contains(item->parentItem()) + ) + { + items.insert(item); + } } QSetIterator itRemoved(cmd->GetRemovedList()); while (itRemoved.hasNext()) { QGraphicsItem* item = itRemoved.next(); - if( !itms.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type())) - itms.insert(item); + if (!items.contains(item) && + !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()) && + !items.contains(item->parentItem()) + ) + { + items.insert(item); + } } } diff --git a/src/board/UBBoardController.h b/src/board/UBBoardController.h index 360e2e71..2f95ed88 100644 --- a/src/board/UBBoardController.h +++ b/src/board/UBBoardController.h @@ -177,7 +177,7 @@ class UBBoardController : public UBDocumentContainer void notifyPageChanged(); void displayMetaData(QMap metadatas); - void findUniquesItems(const QUndoCommand *parent, QSet &itms); + void findUniquesItems(const QUndoCommand *parent, QSet &items); void ClearUndoStack(); void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0, bool forceReload = false, bool onImport = false);