From 487542185d260699d6171b8655f944b3a5a6f7f2 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Sat, 31 May 2025 19:39:11 +0200 Subject: [PATCH 1/2] Revert "[Gui] Fix "Select dependent objects" with cycles" This reverts commit 01effaaab07a836b29a0d502c2dc696a3d807b9f. --- src/Gui/Tree.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 855ce91425..3158d07c2f 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -1303,11 +1303,11 @@ void TreeWidget::addDependentToSelection(App::Document* doc, App::DocumentObject { // add the docObject to the selection Selection().addSelection(doc->getName(), docObject->getNameInDocument()); - // get the dependent objects recursively - auto subObjectList = docObject->getOutListRecursive(); - for (auto itDepend = subObjectList.begin(); itDepend != subObjectList.end(); ++itDepend) { - Selection().addSelection(doc->getName(), (*itDepend)->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)); } // add dependents of the selected tree object to selection From 5cbeef9b33dfd7e52ff2be250763309412e08001 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 18 Apr 2025 19:03:17 +0200 Subject: [PATCH 2/2] Gui: Fix TreeWidget::addDependentToSelection Avoid stack overflow for cyclic dependencies. This fixes issue 20859 --- src/Gui/Tree.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 3158d07c2f..9e00901b96 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -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