modedit: Store single copy of the footprint in undo
When changing elements in the module editor, each element shares the same parent. Undo commits store a copy of the parent as it existed before the change. For footprints with many elements, this creates large, slow undo commits as a copy of the full footprint is stored for each element being edited. This keeps a single copy of the footprint in the undo stack per edit. Fixes: lp:1780526 * https://bugs.launchpad.net/kicad/+bug/1780526
This commit is contained in:
parent
53236a3838
commit
3a09358264
|
@ -458,14 +458,22 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
if( lockFlags == SELECTION_LOCKED )
|
||||
break;
|
||||
|
||||
// Save items, so changes can be undone
|
||||
for( auto item : selection )
|
||||
// When editing modules, all items have the same parent
|
||||
if( EditingModules() )
|
||||
{
|
||||
// Don't double move footprint pads, fields, etc.
|
||||
if( item->GetParent() && item->GetParent()->IsSelected() )
|
||||
continue;
|
||||
m_commit->Modify( selection.Front() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save items, so changes can be undone
|
||||
for( auto item : selection )
|
||||
{
|
||||
// Don't double move footprint pads, fields, etc.
|
||||
if( item->GetParent() && item->GetParent()->IsSelected() )
|
||||
continue;
|
||||
|
||||
m_commit->Modify( item );
|
||||
m_commit->Modify( item );
|
||||
}
|
||||
}
|
||||
|
||||
m_cursor = controls->GetCursorPosition();
|
||||
|
@ -694,9 +702,15 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
|||
updateModificationPoint( selection );
|
||||
const int rotateAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *editFrame, aEvent );
|
||||
|
||||
// When editing modules, all items have the same parent
|
||||
if( EditingModules() )
|
||||
{
|
||||
m_commit->Modify( selection.Front() );
|
||||
}
|
||||
|
||||
for( auto item : selection )
|
||||
{
|
||||
if( !item->IsNew() )
|
||||
if( !item->IsNew() && !EditingModules() )
|
||||
m_commit->Modify( item );
|
||||
|
||||
static_cast<BOARD_ITEM*>( item )->Rotate( selection.GetReferencePoint(), rotateAngle );
|
||||
|
@ -766,6 +780,12 @@ int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
|||
auto refPoint = selection.GetReferencePoint();
|
||||
wxPoint mirrorPoint( refPoint.x, refPoint.y );
|
||||
|
||||
// When editing modules, all items have the same parent
|
||||
if( EditingModules() )
|
||||
{
|
||||
m_commit->Modify( selection.Front() );
|
||||
}
|
||||
|
||||
for( auto item : selection )
|
||||
{
|
||||
// only modify items we can mirror
|
||||
|
@ -775,7 +795,7 @@ int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
|
|||
case PCB_MODULE_TEXT_T:
|
||||
case PCB_PAD_T:
|
||||
// Only create undo entry for items on the board
|
||||
if( !item->IsNew() )
|
||||
if( !item->IsNew() && !EditingModules() )
|
||||
m_commit->Modify( item );
|
||||
|
||||
break;
|
||||
|
@ -839,9 +859,15 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
|
|||
updateModificationPoint( selection );
|
||||
auto modPoint = selection.GetReferencePoint();
|
||||
|
||||
// When editing modules, all items have the same parent
|
||||
if( EditingModules() )
|
||||
{
|
||||
m_commit->Modify( selection.Front() );
|
||||
}
|
||||
|
||||
for( auto item : selection )
|
||||
{
|
||||
if( !item->IsNew() )
|
||||
if( !item->IsNew() && !EditingModules() )
|
||||
m_commit->Modify( item );
|
||||
|
||||
static_cast<BOARD_ITEM*>( item )->Flip( modPoint );
|
||||
|
@ -928,11 +954,17 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
|
|||
// Make sure the rotation is from the right reference point
|
||||
selCenter += translation;
|
||||
|
||||
// When editing modules, all items have the same parent
|
||||
if( EditingModules() )
|
||||
{
|
||||
m_commit->Modify( selection.Front() );
|
||||
}
|
||||
|
||||
for( auto selItem : selection )
|
||||
{
|
||||
BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( selItem );
|
||||
|
||||
if( !item->IsNew() )
|
||||
if( !item->IsNew() && !EditingModules() )
|
||||
m_commit->Modify( item );
|
||||
|
||||
item->Move( translation );
|
||||
|
|
Loading…
Reference in New Issue