From 2c6d0ffe2721825ed6d481f8922dbb3eb67797c0 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 17 Sep 2018 05:34:41 -0700 Subject: [PATCH] pcbnew: retain selection between edits We had been deselecting items after calling edits to be safe in case the item was deleted/exchanged by the edit. The item pointer itself remains valid even when deleting as it is assigned to the undo stack. But it should not remain visible or selected on the schematic if it is removed. This tests for removed items by checking whether it (in the case of first-level BOARD_ITEMS) or its parent (in the case of footprint item components) remain in the view list after editing. If they are still in the view list, then we re-select them. Fixes: lp:1765774 * https://bugs.launchpad.net/kicad/+bug/1765774 Fixes: lp:1775946 * https://bugs.launchpad.net/kicad/+bug/1775946 --- pcbnew/board_commit.cpp | 4 ++++ pcbnew/tools/edit_tool.cpp | 14 ++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 81fbdb7c8e..4a8ec0a326 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -186,6 +187,9 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a { view->Remove( boardItem ); + // Removing an item should trigger the unselect + m_toolMgr->RunAction( PCB_ACTIONS::unselectItem, true, boardItem ); + if( !( changeFlags & CHT_DONE ) ) { MODULE* module = static_cast( boardItem->GetParent() ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index c6a4f9920b..e0d13f48c5 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -676,24 +676,22 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) // Display properties dialog BOARD_ITEM* item = static_cast( selection.Front() ); - // Some of properties dialogs alter pointers, so we should deselect them - m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - - // Store flags, so they can be restored later - STATUS_FLAGS flags = item->GetFlags(); - item->ClearFlags(); - // Do not handle undo buffer, it is done by the properties dialogs @todo LEGACY // Display properties dialog provided by the legacy canvas frame editFrame->OnEditItemRequest( NULL, item ); + // Notify other tools of the changes m_toolMgr->RunAction( PCB_ACTIONS::selectionModified, true ); - item->SetFlags( flags ); } if( selection.IsHover() ) + { m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); + // Notify other tools of the changes -- This updates the visual ratsnest + m_toolMgr->RunAction( PCB_ACTIONS::selectionModified, true ); + } + return 0; }