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
This commit is contained in:
parent
0ff84865ca
commit
2c6d0ffe27
|
@ -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>
|
||||
|
@ -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<MODULE*>( boardItem->GetParent() );
|
||||
|
|
|
@ -676,24 +676,22 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
|||
// Display properties dialog
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue