From bc51c89c90e6099b654e643514baf5b11504bccf Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 25 Feb 2022 13:05:25 +0000 Subject: [PATCH] Reconcile zone-auto-fill with undo. --- cvpcb/display_footprints_frame.h | 25 ++------ include/commit.h | 4 +- include/pcb_base_frame.h | 6 ++ pcbnew/board_commit.cpp | 34 ++++++----- pcbnew/board_commit.h | 13 ++-- pcbnew/edit_zone_helpers.cpp | 2 +- pcbnew/files.cpp | 2 +- pcbnew/footprint_viewer_frame.h | 3 +- pcbnew/pcb_base_edit_frame.h | 9 +++ pcbnew/pcb_edit_frame.cpp | 2 +- .../scripting/pcbnew_action_plugins.cpp | 2 +- pcbnew/tools/drc_tool.cpp | 2 +- pcbnew/tools/zone_filler_tool.cpp | 31 +++++----- pcbnew/undo_redo.cpp | 60 ++++++++++++------- qa/pcbnew/board_test_utils.cpp | 2 +- 15 files changed, 112 insertions(+), 85 deletions(-) diff --git a/cvpcb/display_footprints_frame.h b/cvpcb/display_footprints_frame.h index c14e7500a8..cb7ce9741e 100644 --- a/cvpcb/display_footprints_frame.h +++ b/cvpcb/display_footprints_frame.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2007-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2007-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -87,26 +87,9 @@ public: FOOTPRINT* GetFootprint( const wxString& aFootprintName, REPORTER& aReporter ); - /** - * Does nothing in CvPcb but defined because it is a pure virtual in #PCB_BASE_FRAME. - */ - void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand = UNDO_REDO::UNSPECIFIED ) override - { - } - - - /** - * Create a new entry in undo list of commands. - * - * Add a list of pickers to handle a list of items. - * - * @param aItemsList is the list of items modified by the command to undo - * @param aTypeCommand is command type (see enum UNDO_REDO) - */ - void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aTypeCommand ) override - { - // currently: do nothing in CvPcb. - } + void SaveCopyInUndoList( EDA_ITEM*, UNDO_REDO ) override {} + void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO ) override {} + void AppendCopyToUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO ) override {} SELECTION& GetCurrentSelection() override; diff --git a/include/commit.h b/include/commit.h index 80eef7af13..69f43ba8fc 100644 --- a/include/commit.h +++ b/include/commit.h @@ -131,9 +131,7 @@ public: UNDO_REDO aModFlag = UNDO_REDO::UNSPECIFIED ); ///< Execute the changes. - virtual void Push( const wxString& aMessage = wxT( "A commit" ), - bool aCreateUndoEntry = true, bool aSetDirtyBit = true, - bool aUpdateConnectivity = true, bool aZoneFillOp = false ) = 0; + virtual void Push( const wxString& aMessage = wxT( "A commit" ), int aFlags = 0 ) = 0; ///< Revert the commit by restoring the modified items state. virtual void Revert() = 0; diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h index 51d056c0cc..c655b30515 100644 --- a/include/pcb_base_frame.h +++ b/include/pcb_base_frame.h @@ -333,6 +333,12 @@ public: virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aTypeCommand ) = 0; + /** + * As SaveCopyInUndoList, but appends the changes to the last undo item on the stack. + */ + virtual void AppendCopyToUndoList( const PICKED_ITEMS_LIST& aItemsList, + UNDO_REDO aTypeCommand ) = 0; + /** * Show the dialog box for a layer selection. diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index b02a04a23d..823c9471a4 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -140,8 +140,7 @@ void BOARD_COMMIT::dirtyIntersectingZones( BOARD_ITEM* item ) } -void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool aSetDirtyBit, - bool aUpdateConnectivity, bool aZoneFillOp ) +void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags ) { // Objects potentially interested in changes: PICKED_ITEMS_LIST undoList; @@ -161,7 +160,9 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a if( Empty() ) return; - if( m_isBoardEditor && !aZoneFillOp && frame->GetPcbNewSettings()->m_AutoRefillZones ) + if( m_isBoardEditor + && !( aCommitFlags & ZONE_FILL_OP ) + && frame->GetPcbNewSettings()->m_AutoRefillZones ) { autofillZones = true; @@ -199,7 +200,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a wxASSERT( ent.m_item->Type() == PCB_FOOTPRINT_T ); wxASSERT( ent.m_copy->Type() == PCB_FOOTPRINT_T ); - if( aCreateUndoEntry && frame ) + if( !( aCommitFlags & SKIP_UNDO ) ) { ITEM_PICKER itemWrapper( nullptr, ent.m_item, UNDO_REDO::CHANGED ); itemWrapper.SetLink( ent.m_copy ); @@ -248,7 +249,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a } else { - if( aCreateUndoEntry ) + if( !( aCommitFlags & SKIP_UNDO ) ) undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::NEWITEM ) ); if( !( changeFlags & CHT_DONE ) ) @@ -271,7 +272,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a { PCB_GROUP* parentGroup = boardItem->GetParentGroup(); - if( !m_isFootprintEditor && aCreateUndoEntry ) + if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) ) undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::DELETED ) ); if( boardItem->IsSelected() ) @@ -403,7 +404,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a case CHT_MODIFY: { - if( !m_isFootprintEditor && aCreateUndoEntry ) + if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) ) { ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED ); wxASSERT( ent.m_copy ); @@ -411,7 +412,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a undoList.PushItem( itemWrapper ); } - if( aUpdateConnectivity ) + if( !( aCommitFlags & SKIP_CONNECTIVITY ) ) { std::shared_ptr connectivity = board->GetConnectivity(); @@ -444,7 +445,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a itemsChanged.push_back( boardItem ); // if no undo entry is needed, the copy would create a memory leak - if( !aCreateUndoEntry ) + if( aCommitFlags & SKIP_UNDO ) delete ent.m_copy; break; @@ -469,7 +470,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a { size_t num_changes = m_changes.size(); - if( aUpdateConnectivity ) + if( !( aCommitFlags & SKIP_CONNECTIVITY ) ) { std::shared_ptr connectivity = board->GetConnectivity(); @@ -494,7 +495,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a BOARD_ITEM* boardItem = static_cast( ent.m_item ); - if( aCreateUndoEntry ) + if( !( aCommitFlags & SKIP_UNDO ) ) { ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED ); wxASSERT( ent.m_copy ); @@ -511,8 +512,13 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a } } - if( m_isBoardEditor && aCreateUndoEntry ) - frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED ); + if( m_isBoardEditor && !( aCommitFlags & SKIP_UNDO ) ) + { + if( aCommitFlags & APPEND_UNDO ) + frame->AppendCopyToUndoList( undoList, UNDO_REDO::UNSPECIFIED ); + else + frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED ); + } m_toolMgr->PostEvent( { TC_MESSAGE, TA_MODEL_CHANGE, AS_GLOBAL } ); @@ -524,7 +530,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a if( frame ) { - if( aSetDirtyBit ) + if( !( aCommitFlags & SKIP_SET_DIRTY ) ) frame->OnModify(); else frame->Update3DView( true, frame->Settings().m_Display.m_Live3DRefresh ); diff --git a/pcbnew/board_commit.h b/pcbnew/board_commit.h index b1042afddc..8a819ffc82 100644 --- a/pcbnew/board_commit.h +++ b/pcbnew/board_commit.h @@ -35,6 +35,12 @@ class TOOL_MANAGER; class EDA_DRAW_FRAME; class TOOL_BASE; +#define SKIP_UNDO 0x0001 +#define APPEND_UNDO 0x0002 +#define SKIP_SET_DIRTY 0x0004 +#define SKIP_CONNECTIVITY 0x0008 +#define ZONE_FILL_OP 0x0010 + class BOARD_COMMIT : public COMMIT { public: @@ -45,14 +51,13 @@ public: virtual ~BOARD_COMMIT(); virtual void Push( const wxString& aMessage = wxT( "A commit" ), - bool aCreateUndoEntry = true, bool aSetDirtyBit = true, - bool aUpdateConnectivity = true, bool aZoneFillOp = false ) override; + int aCommitFlags = 0 ) override; virtual void Revert() override; COMMIT& Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType ) override; COMMIT& Stage( std::vector& container, CHANGE_TYPE aChangeType ) override; - COMMIT& Stage( - const PICKED_ITEMS_LIST& aItems, UNDO_REDO aModFlag = UNDO_REDO::UNSPECIFIED ) override; + COMMIT& Stage( const PICKED_ITEMS_LIST& aItems, + UNDO_REDO aModFlag = UNDO_REDO::UNSPECIFIED ) override; /** * Sets a flag that will cause Push() to resolve net conflicts on track/via clusters instead diff --git a/pcbnew/edit_zone_helpers.cpp b/pcbnew/edit_zone_helpers.cpp index 182a24fe05..aacec6eed2 100644 --- a/pcbnew/edit_zone_helpers.cpp +++ b/pcbnew/edit_zone_helpers.cpp @@ -103,7 +103,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE* aZone ) commit.Stage( pickedList ); - commit.Push( _( "Modify zone properties" ), true, true, false ); + commit.Push( _( "Modify zone properties" ), SKIP_CONNECTIVITY ); GetBoard()->GetConnectivity()->Build( GetBoard() ); pickedList.ClearItemsList(); // s_ItemsListPicker is no longer owner of picked items diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 4262d6291c..38ec02039f 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -967,7 +967,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in filler.SetProgressReporter( &progressReporter ); if( filler.Fill( toFill ) ) - commit.Push( _( "Convert Zone(s)" ), true, true, false ); + commit.Push( _( "Convert Zone(s)" ), SKIP_CONNECTIVITY ); GetBoard()->BuildConnectivity( &progressReporter ); } diff --git a/pcbnew/footprint_viewer_frame.h b/pcbnew/footprint_viewer_frame.h index b7554d3698..cc6062ef7b 100644 --- a/pcbnew/footprint_viewer_frame.h +++ b/pcbnew/footprint_viewer_frame.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 Jean-Pierre Charras, jap.charras at wanadoo.fr - * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -157,6 +157,7 @@ private: void SaveCopyInUndoList( EDA_ITEM*, UNDO_REDO ) override {} void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO ) override {} + void AppendCopyToUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO ) override {} void updateView(); diff --git a/pcbnew/pcb_base_edit_frame.h b/pcbnew/pcb_base_edit_frame.h index 8b8b3d028e..c19b57200c 100644 --- a/pcbnew/pcb_base_edit_frame.h +++ b/pcbnew/pcb_base_edit_frame.h @@ -102,6 +102,12 @@ public: */ void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aCommandType ) override; + /** + * As SaveCopyInUndoList, but appends the changes to the last undo item on the stack. + */ + void AppendCopyToUndoList( const PICKED_ITEMS_LIST& aItemsList, + UNDO_REDO aCommandType ) override; + /** * Redo the last edit: * - Save the current board in Undo list @@ -224,6 +230,9 @@ protected: void handleActivateEvent( wxActivateEvent& aEvent ) override; + void saveCopyInUndoList( PICKED_ITEMS_LIST* commandToUndo, const PICKED_ITEMS_LIST& aItemsList, + UNDO_REDO aCommandType ); + void unitsChangeRefresh() override; protected: diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index c33cce18d6..4d2cb6f1e6 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -877,7 +877,7 @@ void PCB_EDIT_FRAME::ResolveDRCExclusions() for( PCB_MARKER* marker : GetBoard()->ResolveDRCExclusions() ) commit.Add( marker ); - commit.Push( wxEmptyString, false, false ); + commit.Push( wxEmptyString, SKIP_UNDO | SKIP_SET_DIRTY ); for( PCB_MARKER* marker : GetBoard()->Markers() ) { diff --git a/pcbnew/python/scripting/pcbnew_action_plugins.cpp b/pcbnew/python/scripting/pcbnew_action_plugins.cpp index c9f712f2ce..e9d499a07e 100644 --- a/pcbnew/python/scripting/pcbnew_action_plugins.cpp +++ b/pcbnew/python/scripting/pcbnew_action_plugins.cpp @@ -371,7 +371,7 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin ) } // Apply changes, UndoList already handled - commit.Push( _( "Apply action script" ), false ); + commit.Push( _( "Apply action script" ), SKIP_UNDO | SKIP_SET_DIRTY ); ActivateGalCanvas(); } diff --git a/pcbnew/tools/drc_tool.cpp b/pcbnew/tools/drc_tool.cpp index e35bb6a59f..c39d63fb61 100644 --- a/pcbnew/tools/drc_tool.cpp +++ b/pcbnew/tools/drc_tool.cpp @@ -192,7 +192,7 @@ void DRC_TOOL::RunTests( PROGRESS_REPORTER* aProgressReporter, bool aRefillZones m_drcDialog->SetFootprintTestsRun(); } - commit.Push( _( "DRC" ), false ); + commit.Push( _( "DRC" ), SKIP_UNDO ); m_drcRunning = false; diff --git a/pcbnew/tools/zone_filler_tool.cpp b/pcbnew/tools/zone_filler_tool.cpp index 13883c13ca..f4749d595e 100644 --- a/pcbnew/tools/zone_filler_tool.cpp +++ b/pcbnew/tools/zone_filler_tool.cpp @@ -86,7 +86,7 @@ void ZONE_FILLER_TOOL::CheckAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRep if( filler.Fill( toFill, true, aCaller ) ) { - commit.Push( _( "Fill Zone(s)" ), true, true, false, true ); + commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP ); getEditFrame()->m_ZoneFillsDirty = false; } else @@ -161,7 +161,7 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo { filler.GetProgressReporter()->AdvancePhase(); - commit.Push( _( "Fill Zone(s)" ), true, true, false, true ); + commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP ); frame->m_ZoneFillsDirty = false; } else @@ -247,7 +247,7 @@ int ZONE_FILLER_TOOL::ZoneFillDirty( const TOOL_EVENT& aEvent ) } if( filler.Fill( toFill ) ) - commit.Push( _( "Auto-fill Zone(s)" ), false, false, false, true ); + commit.Push( _( "Auto-fill Zone(s)" ), APPEND_UNDO | SKIP_CONNECTIVITY | ZONE_FILL_OP ); else commit.Revert(); @@ -270,19 +270,20 @@ int ZONE_FILLER_TOOL::ZoneFillDirty( const TOOL_EVENT& aEvent ) { WX_INFOBAR* infobar = frame->GetInfoBar(); -#ifdef __WXMAC__ // I haven't a clue why this is needed, but if you start another operation before the // animation is over then you end up accessing deleted view items. - infobar->SetShowHideEffects( wxSHOW_EFFECT_NONE, wxSHOW_EFFECT_NONE ); -#endif + wxShowEffect savedShowEffect = infobar->GetShowEffect(); + wxShowEffect savedHideEffect = infobar->GetHideEffect(); + int savedEffectDuration = infobar->GetEffectDuration(); - infobar->RemoveAllButtons(); - infobar->ShowMessageFor( _( "Zone has no connections." ), 4000, wxICON_WARNING ); + infobar->SetShowHideEffects( wxSHOW_EFFECT_NONE, wxSHOW_EFFECT_NONE ); + { + infobar->RemoveAllButtons(); + infobar->ShowMessageFor( _( "Zone has no connections." ), 4000, wxICON_WARNING ); + } + infobar->SetShowHideEffects( savedShowEffect, savedHideEffect ); + infobar->SetEffectDuration( savedEffectDuration ); -#ifdef __WXMAC__ - infobar->SetShowHideEffects( wxSHOW_EFFECT_ROLL_TO_BOTTOM, wxSHOW_EFFECT_ROLL_TO_TOP ); - infobar->SetEffectDuration( 300 ); -#endif break; } } @@ -330,7 +331,7 @@ int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent ) if( filler.Fill( toFill ) ) { reporter->AdvancePhase(); - commit.Push( _( "Fill Zone(s)" ), true, true, false, true ); + commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP ); } else { @@ -367,7 +368,7 @@ int ZONE_FILLER_TOOL::ZoneUnfill( const TOOL_EVENT& aEvent ) zone->UnFill(); } - commit.Push( _( "Unfill Zone" ), true, true, true, true ); + commit.Push( _( "Unfill Zone" ), ZONE_FILL_OP ); canvas()->Refresh(); return 0; @@ -385,7 +386,7 @@ int ZONE_FILLER_TOOL::ZoneUnfillAll( const TOOL_EVENT& aEvent ) zone->UnFill(); } - commit.Push( _( "Unfill All Zones" ), true, true, true, true ); + commit.Push( _( "Unfill All Zones" ), ZONE_FILL_OP ); canvas()->Refresh(); return 0; diff --git a/pcbnew/undo_redo.cpp b/pcbnew/undo_redo.cpp index db097900e5..f73c9872fd 100644 --- a/pcbnew/undo_redo.cpp +++ b/pcbnew/undo_redo.cpp @@ -176,18 +176,11 @@ static void SwapItemData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) } -void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* aItem, UNDO_REDO aCommandType ) -{ - PICKED_ITEMS_LIST commandToUndo; - commandToUndo.PushItem( ITEM_PICKER( nullptr, aItem, aCommandType ) ); - SaveCopyInUndoList( commandToUndo, aCommandType ); -} - - -void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, +void PCB_BASE_EDIT_FRAME::saveCopyInUndoList( PICKED_ITEMS_LIST* commandToUndo, + const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aCommandType ) { - PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); + int preExisting = commandToUndo->GetCount(); // First, filter unnecessary stuff from the list (i.e. for multiple pads / labels modified), // take the first occurrence of the footprint (we save copies of footprints when one of its @@ -250,9 +243,9 @@ void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsLis } } - for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ ) + for( unsigned ii = preExisting; ii < commandToUndo->GetCount(); ii++ ) { - EDA_ITEM* item = aItemsList.GetPickedItem( ii ); + EDA_ITEM* item = commandToUndo->GetPickedItem( ii ); UNDO_REDO command = commandToUndo->GetPickedItemStatus( ii ); if( command == UNDO_REDO::UNSPECIFIED ) @@ -269,15 +262,9 @@ void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsLis case UNDO_REDO::DRILLORIGIN: case UNDO_REDO::GRIDORIGIN: - /* If needed, create a copy of item, and put in undo list - * in the picker, as link - * If this link is not null, the copy is already done - */ - if( commandToUndo->GetPickedItemLink( ii ) == nullptr ) - { - EDA_ITEM* cloned = item->Clone(); - commandToUndo->SetPickedItemLink( cloned, ii ); - } + // If we don't yet have a copy in the link, set one up + if( !commandToUndo->GetPickedItemLink( ii ) ) + commandToUndo->SetPickedItemLink( item->Clone(), ii ); break; @@ -312,6 +299,37 @@ void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsLis } +void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* aItem, UNDO_REDO aCommandType ) +{ + PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); + PICKED_ITEMS_LIST itemsList; + + itemsList.PushItem( ITEM_PICKER( nullptr, aItem, aCommandType ) ); + saveCopyInUndoList( commandToUndo, itemsList, aCommandType ); +} + + +void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, + UNDO_REDO aCommandType ) +{ + PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); + + saveCopyInUndoList( commandToUndo, aItemsList, aCommandType ); +} + + +void PCB_BASE_EDIT_FRAME::AppendCopyToUndoList( const PICKED_ITEMS_LIST& aItemsList, + UNDO_REDO aCommandType ) +{ + PICKED_ITEMS_LIST* commandToUndo = PopCommandFromUndoList(); + + if( !commandToUndo ) + commandToUndo = new PICKED_ITEMS_LIST(); + + saveCopyInUndoList( commandToUndo, aItemsList, aCommandType ); +} + + void PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList( wxCommandEvent& aEvent ) { if( UndoRedoBlocked() ) diff --git a/qa/pcbnew/board_test_utils.cpp b/qa/pcbnew/board_test_utils.cpp index 2b4c379464..90b15c257a 100644 --- a/qa/pcbnew/board_test_utils.cpp +++ b/qa/pcbnew/board_test_utils.cpp @@ -118,7 +118,7 @@ void FillZones( BOARD* m_board ) toFill.push_back( zone ); if( filler.Fill( toFill, false, nullptr ) ) - commit.Push( _( "Fill Zone(s)" ), false, false ); + commit.Push( _( "Fill Zone(s)" ), SKIP_UNDO | SKIP_SET_DIRTY | ZONE_FILL_OP ); }