From f6fa2f0d2cd19f2fa5fd8e067f672bb0aff659ef Mon Sep 17 00:00:00 2001 From: forbes Date: Wed, 4 Mar 2026 16:16:05 -0600 Subject: [PATCH] fix(editing-context): trust parentId chain without re-checking ancestor match() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parent match() functions are designed for flat priority resolution and may not return true when a more specific child is active (e.g. assembly.idle checks getActivePartObject() which may not return the assembly during edit mode). The parentId declaration is the author's assertion of structural containment — the leaf already matched, so we walk the full chain unconditionally. --- src/Gui/EditingContext.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Gui/EditingContext.cpp b/src/Gui/EditingContext.cpp index 5d9dd4d9a9..03a2383c61 100644 --- a/src/Gui/EditingContext.cpp +++ b/src/Gui/EditingContext.cpp @@ -660,7 +660,13 @@ QString EditingContextResolver::expandLabel(const ContextDefinition& def) const void EditingContextResolver::buildStack(EditingContext& ctx, const ContextDefinition& leaf) const { - // Walk from leaf up through parentId chain, verifying each ancestor matches + // Walk from leaf up through parentId chain. + // We trust the parentId declarations — the leaf already matched, and the + // hierarchy is the addon author's assertion of structural containment. + // Parent match() functions are designed for flat priority resolution and + // may not return true when a more specific child is active (e.g. + // assembly.idle won't match during assembly.edit because the "part" + // active object changes during edit mode). QStringList reverseStack; reverseStack.append(leaf.id); @@ -675,15 +681,8 @@ void EditingContextResolver::buildStack(EditingContext& ctx, reverseStack.last().toUtf8().constData()); break; } - // Only include parent if it matches current state - if (parentDef->match && parentDef->match()) { - reverseStack.append(parentDef->id); - currentParent = parentDef->parentId; - } - else { - // Parent doesn't match — stop climbing (partial stack) - break; - } + reverseStack.append(parentDef->id); + currentParent = parentDef->parentId; } // Reverse to get root-to-leaf order