From e26ffd782ab835620507d3ef2d11fc4d8acea96e Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 26 Nov 2025 14:20:23 -0600 Subject: [PATCH] GUI: fix "select all instances" (#25503) --- src/Gui/Tree.cpp | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 05a5d5955e..ba66ba0714 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -6539,20 +6539,37 @@ int DocumentObjectItem::getSubName(std::ostringstream& str, App::DocumentObject* int group = parent->isGroup(); if (group == NotGroup) { if (ret != PartGroup) { - // Handle this situation, - // - // LinkGroup - // |--PartExtrude - // |--Sketch - // - // This function traverse from top down, so, when seeing a - // non-group object 'PartExtrude', its following children should - // not be grouped, so must reset any previous parents here. - topParent = nullptr; - str.str(""); // reset the current subname - return NotGroup; + // check if the parent explicitly claims this child, + // if so, we should include the parent in the subname path + auto children = parent->object()->claimChildren(); + bool parentClaimsThis = false; + for (auto child : children) { + if (child == object()->getObject()) { + parentClaimsThis = true; + break; + } + } + + if (!parentClaimsThis) { + // Handle this situation, + // + // LinkGroup + // |--PartExtrude + // |--Sketch + // + // This function traverse from top down, so, when seeing a + // non-group object 'PartExtrude', its following children should + // not be grouped, so must reset any previous parents here. + topParent = nullptr; + str.str(""); // reset the current subname + return NotGroup; + } + // if parent claims this child, treat it like a PartGroup + group = PartGroup; + } + else { + group = PartGroup; } - group = PartGroup; } ret = group; }