Gui: Fix TreeWidget::addDependentToSelection

Avoid stack overflow for cyclic dependencies.

This fixes issue 20859
This commit is contained in:
wmayer
2025-04-18 19:03:17 +02:00
committed by Ladislav Michl
parent 487542185d
commit 5cbeef9b33

View File

@@ -1305,9 +1305,11 @@ void TreeWidget::addDependentToSelection(App::Document* doc, App::DocumentObject
Selection().addSelection(doc->getName(), docObject->getNameInDocument());
// get the dependent
auto subObjectList = docObject->getOutList();
// the dependent can in turn have dependents, thus add them recursively
for (auto itDepend = subObjectList.begin(); itDepend != subObjectList.end(); ++itDepend)
addDependentToSelection(doc, (*itDepend));
for (auto itDepend : subObjectList) {
if (!Selection().isSelected(itDepend)) {
addDependentToSelection(doc, itDepend);
}
}
}
// add dependents of the selected tree object to selection