From b46453648bcfb7c808e80b8f5395c2986d0a7bce Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 24 Oct 2024 22:39:27 +0200 Subject: [PATCH] Core: Handle possible nested calls of TreeWidget::onUpdateStatus() Fixes #17460 --- src/Gui/Tree.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 5c1a6dc6a7..877d82ffdc 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -2982,8 +2982,12 @@ void TreeWidget::onUpdateStatus() std::vector errors; + // Use a local copy in case of nested calls + auto localNewObjects = NewObjects; + NewObjects.clear(); + // Checking for new objects - for (auto& v : NewObjects) { + for (auto& v : localNewObjects) { auto doc = App::GetApplication().getDocument(v.first.c_str()); if (!doc) continue; @@ -3006,10 +3010,13 @@ void TreeWidget::onUpdateStatus() docItem->createNewItem(*vpd); } } - NewObjects.clear(); + + // Use a local copy in case of nested calls + auto localChangedObjects = ChangedObjects; + ChangedObjects.clear(); // Update children of changed objects - for (auto& v : ChangedObjects) { + for (auto& v : localChangedObjects) { auto obj = v.first; auto iter = ObjectTable.find(obj); @@ -3035,7 +3042,6 @@ void TreeWidget::onUpdateStatus() updateChildren(iter->first, iter->second, v.second.test(CS_Output), false); } - ChangedObjects.clear(); FC_LOG("update item status"); TimingInit();