From a44ac7d29b2ec033b60383a7be2706c5349da71b Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 16 Feb 2026 09:52:56 -0800 Subject: [PATCH] Fix COMMIT::Stage assertion when CHT_DONE set on CHT_MODIFY When undoLevelItem() remaps a child item to its parent, the change type is forced to CHT_MODIFY but the CHT_DONE flag from the original CHT_ADD/CHT_REMOVE was left intact. CHT_DONE means the original add/remove was already applied to the child, but that semantic doesn't carry over when we remap to a modify of the parent. Strip CHT_DONE at the remapping site instead of as a general catch-all. Keep the assertion as defense-in-depth for any future code path that might combine CHT_MODIFY with CHT_DONE directly. Fixes KICAD-102A --- common/commit.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/commit.cpp b/common/commit.cpp index 2d0e7871fe..722440e394 100644 --- a/common/commit.cpp +++ b/common/commit.cpp @@ -50,11 +50,15 @@ COMMIT& COMMIT::Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType, BASE_SCREEN* aS EDA_ITEM* undoItem = undoLevelItem( aItem ); if( undoItem != aItem ) + { changeType = CHT_MODIFY; - // CHT_MODIFY and CHT_DONE are not compatible - if( changeType == CHT_MODIFY ) - wxASSERT( ( flags & CHT_DONE ) == 0 ); + // CHT_DONE means the original add/remove was already applied to the child, but that + // semantic doesn't carry over when we remap to a modify of the parent + flags &= ~CHT_DONE; + } + + wxASSERT( changeType != CHT_MODIFY || ( flags & CHT_DONE ) == 0 ); switch( changeType ) {