From e33fc007c78b29075d0fae5973e68ac1ddb47f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fauconnier?= Date: Fri, 17 Dec 2021 10:24:12 +0100 Subject: [PATCH] prevent a crash when clearBackground then undo then redo then clearBackground --- src/domain/UBGraphicsItemUndoCommand.cpp | 6 +++++- src/domain/UBGraphicsScene.cpp | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/domain/UBGraphicsItemUndoCommand.cpp b/src/domain/UBGraphicsItemUndoCommand.cpp index 4787aed5..8ad68b22 100644 --- a/src/domain/UBGraphicsItemUndoCommand.cpp +++ b/src/domain/UBGraphicsItemUndoCommand.cpp @@ -246,7 +246,11 @@ void UBGraphicsItemUndoCommand::redo() polygonItem->strokesGroup()->removeFromGroup(polygonItem); } - mScene->removeItem(item); + + if (itemLayerType::BackgroundItem == item->data(UBGraphicsItemData::itemLayerType)) + mScene->setAsBackgroundObject(nullptr); + else + mScene->removeItem(item); if (bApplyTransform) item->setTransform(t); diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 0336a63c..533b97c1 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -1476,6 +1476,7 @@ void UBGraphicsScene::clearContent(clearCase pCase) if(mBackgroundObject){ removeItem(mBackgroundObject); removedItems << mBackgroundObject; + mBackgroundObject = nullptr; } break;