Don't push a commit we don't own.

This commit is contained in:
Jeff Young 2023-10-22 17:34:32 +01:00
parent 5da35d7750
commit ad676e22b8
5 changed files with 33 additions and 25 deletions

View File

@ -147,6 +147,8 @@ public:
///< Returns status of an item.
int GetStatus( EDA_ITEM* aItem, BASE_SCREEN *aScreen = nullptr );
EDA_ITEM* GetFirst() const { return m_changes.empty() ? nullptr : m_changes[0].m_item; }
protected:
struct COMMIT_LINE
{

View File

@ -2453,6 +2453,20 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
sTool->FilterCollectorForFreePads( aCollector, true );
sTool->FilterCollectorForMarkers( aCollector );
sTool->FilterCollectorForHierarchy( aCollector, true );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[i];
if( item->Type() == PCB_GENERATOR_T )
{
// Could you duplicate something like a generated stitching pattern?
// Dunno. But duplicating a tuning pattern is a sure crash.
//
aCollector.Remove( item );
}
}
} );
if( selection.Empty() )

View File

@ -238,9 +238,19 @@ int EDIT_TOOL::Move( const TOOL_EVENT& aEvent )
BOARD_COMMIT localCommit( this );
if( doMoveSelection( aEvent, &localCommit ) )
localCommit.Push( _( "Move" ) );
{
if( PCB_GENERATOR* genItem = dynamic_cast<PCB_GENERATOR*>( localCommit.GetFirst() ) )
m_toolMgr->RunSynchronousAction( PCB_ACTIONS::genPushEdit, &localCommit, genItem );
else
localCommit.Push( _( "Move" ) );
}
else
localCommit.Revert();
{
if( PCB_GENERATOR* genItem = dynamic_cast<PCB_GENERATOR*>( localCommit.GetFirst() ) )
m_toolMgr->RunSynchronousAction( PCB_ACTIONS::genRevertEdit, &localCommit, genItem );
else
localCommit.Revert();
}
}
return 0;
@ -798,26 +808,6 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit
{
EDA_ITEMS oItems( orig_items.begin(), orig_items.end() );
m_toolMgr->RunAction<EDA_ITEMS*>( PCB_ACTIONS::selectItems, &oItems );
for( BOARD_ITEM* item : sel_items )
{
if( item->Type() == PCB_GENERATOR_T )
{
m_toolMgr->RunSynchronousAction( PCB_ACTIONS::genPushEdit, aCommit,
static_cast<PCB_GENERATOR*>( item ) );
}
}
}
else
{
for( BOARD_ITEM* item : sel_items )
{
if( item->Type() == PCB_GENERATOR_T )
{
m_toolMgr->RunSynchronousAction( PCB_ACTIONS::genRevertEdit, aCommit,
static_cast<PCB_GENERATOR*>( item ) );
}
}
}
// Remove the dynamic ratsnest from the screen

View File

@ -240,7 +240,7 @@ int GENERATOR_TOOL::GenEditAction( const TOOL_EVENT& aEvent )
}
else if( aEvent.IsAction( &PCB_ACTIONS::genPushEdit ) )
{
gen->EditPush( this, board(), frame(), commit, wxEmptyString, APPEND_UNDO );
gen->EditPush( this, board(), frame(), commit, wxEmptyString );
wxASSERT( commit->Empty() );
}

View File

@ -654,8 +654,10 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
m_toolMgr->RunSynchronousAction( PCB_ACTIONS::genPushEdit, &commit,
static_cast<PCB_GENERATOR*>( item ) );
}
commit.Push( _( "Drag Corner" ) );
else
{
commit.Push( _( "Drag Corner" ) );
}
inDrag = false;
frame()->UndoRedoBlock( false );