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.
( cherry-picked from 2c6d0ffe2 )
Fixes: lp:1765774
* https://bugs.launchpad.net/kicad/+bug/1765774
Fixes: lp:1775946
* https://bugs.launchpad.net/kicad/+bug/1775946
This commit is contained in:
+11
-2
@@ -30,6 +30,7 @@
|
||||
#include <view/view.h>
|
||||
#include <board_commit.h>
|
||||
#include <tools/pcb_tool.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
#include <connectivity_data.h>
|
||||
|
||||
#include <functional>
|
||||
@@ -165,6 +166,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<MODULE*>( boardItem->GetParent() );
|
||||
@@ -188,6 +192,9 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
||||
case PCB_ZONE_AREA_T:
|
||||
view->Remove( boardItem );
|
||||
|
||||
// Removing an item should trigger the unselect
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::unselectItem, true, boardItem );
|
||||
|
||||
if( !( changeFlags & CHT_DONE ) )
|
||||
board->Remove( boardItem );
|
||||
|
||||
@@ -199,10 +206,12 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
||||
wxASSERT( !m_editModules );
|
||||
|
||||
MODULE* module = static_cast<MODULE*>( boardItem );
|
||||
module->ClearFlags();
|
||||
|
||||
view->Remove( module );
|
||||
|
||||
// Removing an item should trigger the unselect
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::unselectItem, true, boardItem );
|
||||
module->ClearFlags();
|
||||
|
||||
if( !( changeFlags & CHT_DONE ) )
|
||||
board->Remove( module ); // handles connectivity
|
||||
|
||||
|
||||
Reference in New Issue
Block a user