Skip to content

Commit 499d192

Browse files
wwmayerchennes
authored andcommitted
Core: Handle possible nested calls of TreeWidget::onUpdateStatus()
Fixes FreeCAD#17460
1 parent 5823046 commit 499d192

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Gui/Tree.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -2982,8 +2982,12 @@ void TreeWidget::onUpdateStatus()
29822982

29832983
std::vector<App::DocumentObject*> errors;
29842984

2985+
// Use a local copy in case of nested calls
2986+
auto localNewObjects = NewObjects;
2987+
NewObjects.clear();
2988+
29852989
// Checking for new objects
2986-
for (auto& v : NewObjects) {
2990+
for (auto& v : localNewObjects) {
29872991
auto doc = App::GetApplication().getDocument(v.first.c_str());
29882992
if (!doc)
29892993
continue;
@@ -3006,10 +3010,13 @@ void TreeWidget::onUpdateStatus()
30063010
docItem->createNewItem(*vpd);
30073011
}
30083012
}
3009-
NewObjects.clear();
3013+
3014+
// Use a local copy in case of nested calls
3015+
auto localChangedObjects = ChangedObjects;
3016+
ChangedObjects.clear();
30103017

30113018
// Update children of changed objects
3012-
for (auto& v : ChangedObjects) {
3019+
for (auto& v : localChangedObjects) {
30133020
auto obj = v.first;
30143021

30153022
auto iter = ObjectTable.find(obj);
@@ -3035,7 +3042,6 @@ void TreeWidget::onUpdateStatus()
30353042

30363043
updateChildren(iter->first, iter->second, v.second.test(CS_Output), false);
30373044
}
3038-
ChangedObjects.clear();
30393045

30403046
FC_LOG("update item status");
30413047
TimingInit();

0 commit comments

Comments
 (0)