From b1adb93c16381bedefdff86e5350ca27ce266556 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 27 Nov 2020 23:33:48 +0000 Subject: [PATCH] PCB_GROUP_Ts need to be added and removed from view. The SELECTION_TOOL's m_enteredGroup also needs to be updated when said group is deleted via undo or redo. Fixes https://gitlab.com/kicad/code/kicad/issues/6493 --- pcbnew/board_commit.cpp | 4 +++- pcbnew/tools/selection_tool.cpp | 39 ++++++++++++++++++++++----------- pcbnew/undo_redo.cpp | 4 ++-- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 4ea5e5d952..ee17fc03ae 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -164,7 +164,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a board->Add( boardItem ); // handles connectivity } - if( boardItem->Type() != PCB_NETINFO_T && boardItem->Type() != PCB_GROUP_T ) + if( boardItem->Type() != PCB_NETINFO_T ) view->Add( boardItem ); break; @@ -246,6 +246,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a break; case PCB_GROUP_T: + view->Remove( boardItem ); + if( !( changeFlags & CHT_DONE ) ) { if( m_isFootprintEditor ) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 0fd909a24f..0c4a185080 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -1602,24 +1602,37 @@ void SELECTION_TOOL::RebuildSelection() { m_selection.Clear(); - INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* testData ) - { - if( item->IsSelected() ) - { - EDA_ITEM* parent = item->GetParent(); + bool enteredGroupFound = false; + + INSPECTOR_FUNC inspector = + [&]( EDA_ITEM* item, void* testData ) + { + if( item->IsSelected() ) + { + EDA_ITEM* parent = item->GetParent(); + + // Flags on footprint children might be set only because the parent is + // selected. + if( parent && parent->Type() == PCB_FOOTPRINT_T && parent->IsSelected() ) + return SEARCH_RESULT::CONTINUE; + + highlight( (BOARD_ITEM*) item, SELECTED, &m_selection ); + } + + if( item == m_enteredGroup ) + enteredGroupFound = true; - // Flags on footprint children might be set only because the parent is selected. - if( parent && parent->Type() == PCB_FOOTPRINT_T && parent->IsSelected() ) return SEARCH_RESULT::CONTINUE; - - highlight( (BOARD_ITEM*) item, SELECTED, &m_selection ); - } - - return SEARCH_RESULT::CONTINUE; - }; + }; board()->Visit( inspector, nullptr, m_isFootprintEditor ? GENERAL_COLLECTOR::FootprintItems : GENERAL_COLLECTOR::AllBoardItems ); + + if( !enteredGroupFound ) + { + m_enteredGroupOverlay.Clear(); + m_enteredGroup = nullptr; + } } diff --git a/pcbnew/undo_redo.cpp b/pcbnew/undo_redo.cpp index 5f2b64a344..4a5fa4077d 100644 --- a/pcbnew/undo_redo.cpp +++ b/pcbnew/undo_redo.cpp @@ -481,7 +481,7 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aList->SetPickedItemStatus( UNDO_REDO::DELETED, ii ); GetModel()->Remove( (BOARD_ITEM*) eda_item ); - if( eda_item->Type() != PCB_NETINFO_T && eda_item->Type() != PCB_GROUP_T ) + if( eda_item->Type() != PCB_NETINFO_T ) view->Remove( eda_item ); break; @@ -490,7 +490,7 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aList->SetPickedItemStatus( UNDO_REDO::NEWITEM, ii ); GetModel()->Add( (BOARD_ITEM*) eda_item ); - if( eda_item->Type() != PCB_NETINFO_T && eda_item->Type() != PCB_GROUP_T ) + if( eda_item->Type() != PCB_NETINFO_T ) view->Add( eda_item ); if( eda_item->Type() == PCB_GROUP_T )