diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 123f97154c..2d58cd614a 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -48,8 +48,6 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType ) { SCH_TEXT* textItem = NULL; - SetRepeatItem( NULL ); - switch( aType ) { case LAYER_NOTES: @@ -157,8 +155,6 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* aText, KICAD_T aType ) if( selected ) m_toolManager->RunAction( SCH_ACTIONS::addItemToSel, true, newtext ); - SetRepeatItem( nullptr ); - delete aText; OnModify(); diff --git a/eeschema/find.cpp b/eeschema/find.cpp index 6bdcb3d878..de89c58fcc 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -335,8 +335,6 @@ void SCH_EDIT_FRAME::OnFindReplace( wxFindDialogEvent& aEvent ) if( undoItem == NULL ) undoItem = item; - SetUndoItem( undoItem ); - sheet = schematic.GetSheetByPath( data.GetSheetPath() ); wxCHECK_RET( sheet != NULL, wxT( "Could not find sheet path " ) + data.GetSheetPath() ); @@ -366,8 +364,6 @@ void SCH_EDIT_FRAME::OnFindReplace( wxFindDialogEvent& aEvent ) if( undoItem == NULL ) undoItem = item; - SetUndoItem( undoItem ); - sheet = schematic.GetSheetByPath( data.GetSheetPath() ); wxCHECK_RET( sheet != NULL, wxT( "Could not find sheet path " ) + data.GetSheetPath() ); diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index 7e8da1f2c3..7f7b142aa1 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -259,9 +259,6 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet() m_toolManager->RunAction( ACTIONS::cancelInteractive, true ); m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true ); - SetRepeatItem( NULL ); - ClearMsgPanel(); - SCH_SCREEN* screen = g_CurrentSheet->LastScreen(); // Switch to current sheet, diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 1c3ab1bfdf..1ce42de330 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -399,7 +399,7 @@ SCH_EDIT_FRAME::~SCH_EDIT_FRAME() Unbind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnEditSymbolLibTable, this, ID_EDIT_SYM_LIB_TABLE ); - delete m_item_to_repeat; // we own the cloned object, see this->SetRepeatItem() + delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem() SetScreen( NULL ); @@ -446,7 +446,7 @@ void SCH_EDIT_FRAME::setupTools() } -void SCH_EDIT_FRAME::SetRepeatItem( SCH_ITEM* aItem ) +void SCH_EDIT_FRAME::SaveCopyForRepeatItem( SCH_ITEM* aItem ) { // we cannot store a pointer to an item in the display list here since // that item may be deleted, such as part of a line concatonation or other. @@ -597,24 +597,6 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) } -void SCH_EDIT_FRAME::SetUndoItem( const SCH_ITEM* aItem ) -{ - // if aItem != NULL, delete a previous m_undoItem, if exists - // if aItme = NULL, just clear m_undoItem, - // because when calling SetUndoItem( NULL ), we only clear m_undoItem, - // because the owner of m_undoItem is no more me. - if( aItem && m_undoItem ) - { - delete m_undoItem; - } - - m_undoItem = NULL; - - if( aItem ) - m_undoItem = (SCH_ITEM*) aItem->Clone(); -} - - void SCH_EDIT_FRAME::SaveUndoItemInUndoList( SCH_ITEM* aItem, bool aAppend ) { wxCHECK_RET( aItem != NULL, @@ -1259,7 +1241,7 @@ void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_ITEM* aItem, bool aUndoAppe if( !screen->CheckIfOnDrawList( aItem ) ) // don't want a loop! AddToScreen( aItem ); - SetRepeatItem( aItem ); + SaveCopyForRepeatItem( aItem ); SaveCopyInUndoList( undoItem, UR_NEW, aUndoAppend ); } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index e1f0129776..25d530e2cc 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -1073,7 +1073,7 @@ public: /** * Clone \a aItem and owns that clone in this container. */ - void SetRepeatItem( SCH_ITEM* aItem ); + void SaveCopyForRepeatItem( SCH_ITEM* aItem ); /** * Return the item which is to be repeated with the insert key. @@ -1082,17 +1082,6 @@ public: */ SCH_ITEM* GetRepeatItem() const { return m_item_to_repeat; } - /** - * Clone \a aItem which can be used to restore the state of the item being edited - * when the user cancels the editing in progress. - * - * @param aItem The item to make a clone of for undoing the last change. Set to - * NULL to free the current undo item. - */ - void SetUndoItem( const SCH_ITEM* aItem ); - - SCH_ITEM* GetUndoItem() const { return m_undoItem; } - /** * Swap the cloned item in member variable m_undoItem with \a aItem and saves it to * the undo list then swap the data back. diff --git a/eeschema/tools/lib_drawing_tools.cpp b/eeschema/tools/lib_drawing_tools.cpp index 27a8e798ee..a63ee5b135 100644 --- a/eeschema/tools/lib_drawing_tools.cpp +++ b/eeschema/tools/lib_drawing_tools.cpp @@ -196,6 +196,7 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType ) // First click creates... if( !item ) { + m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); m_frame->GetCanvas()->SetIgnoreMouseEvents( true ); switch( aType ) @@ -340,6 +341,8 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) if( !part ) continue; + m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); + switch( m_frame->GetToolId() ) { case ID_LIBEDIT_BODY_ARC_BUTT: item = new LIB_ARC( part ); break; diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 90d41b75f2..c57257950e 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -144,7 +144,7 @@ SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() : m_frame( nullptr ), m_menu( *this ) { -}; +} SCH_DRAWING_TOOLS::~SCH_DRAWING_TOOLS() @@ -288,7 +288,6 @@ int SCH_DRAWING_TOOLS::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTE if( !aComponent ) { m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); - m_frame->SetRepeatItem( nullptr ); // Pick the module to be placed m_frame->GetCanvas()->SetIgnoreMouseEvents( true ); @@ -315,7 +314,7 @@ int SCH_DRAWING_TOOLS::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTE if( m_frame->GetAutoplaceFields() ) aComponent->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false ); - m_frame->SetRepeatItem( aComponent ); + m_frame->SaveCopyForRepeatItem( aComponent ); m_view->ClearPreview(); m_view->AddToPreview( aComponent->Clone() ); @@ -415,11 +414,13 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) { if( !image ) { - wxFileDialog dlg( m_frame, _( "Choose Image" ), wxEmptyString, wxEmptyString, - _( "Image Files " ) + wxImage::GetImageExtWildcard(), wxFD_OPEN ); + m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); m_frame->GetCanvas()->SetIgnoreMouseEvents( true ); + wxFileDialog dlg( m_frame, _( "Choose Image" ), wxEmptyString, wxEmptyString, + _( "Image Files " ) + wxImage::GetImageExtWildcard(), wxFD_OPEN ); + if( dlg.ShowModal() != wxID_OK ) continue; @@ -443,7 +444,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) image->SetFlags( IS_NEW | IS_MOVED ); - m_frame->SetRepeatItem( image ); + m_frame->SaveCopyForRepeatItem( image ); m_view->ClearPreview(); m_view->AddToPreview( image->Clone() ); @@ -564,7 +565,7 @@ int SCH_DRAWING_TOOLS::doSingleClickPlace( KICAD_T aType ) item->SetFlags( IS_NEW ); m_frame->AddItemToScreenAndUndoList( item ); - m_frame->SetRepeatItem( item ); + m_frame->SaveCopyForRepeatItem( item ); m_frame->SchematicCleanUp(); m_frame->TestDanglingEnds(); @@ -662,7 +663,7 @@ int SCH_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType ) // First click creates... if( !item ) { - m_frame->SetRepeatItem( NULL ); + m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); m_frame->GetCanvas()->SetIgnoreMouseEvents( true ); switch( aType ) @@ -794,6 +795,8 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent ) else if( evt->IsClick( BUT_LEFT ) && !sheet ) { + m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); + sheet = new SCH_SHEET( (wxPoint) cursorPos ); sheet->SetFlags( IS_NEW | IS_RESIZED ); sheet->SetTimeStamp( GetNewTimeStamp() ); @@ -801,8 +804,6 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent ) sheet->SetScreen( NULL ); sizeSheet( sheet, cursorPos ); - m_frame->SetRepeatItem( nullptr ); - m_selectionTool->AddItemToSel( sheet ); m_view->ClearPreview(); m_view->AddToPreview( sheet->Clone() ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 8f7a841e68..1f8f4712bb 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -899,7 +899,7 @@ int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent ) m_frame->TestDanglingEnds(); // newItem newItem, now that it has been moved, thus saving new position. - m_frame->SetRepeatItem( newItem ); + m_frame->SaveCopyForRepeatItem( newItem ); return 0; } @@ -959,7 +959,6 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) } } - m_frame->SetRepeatItem( nullptr ); m_frame->TestDanglingEnds(); m_frame->GetCanvas()->Refresh(); diff --git a/eeschema/tools/sch_wire_bus_tool.cpp b/eeschema/tools/sch_wire_bus_tool.cpp index 27f9a119f3..e28d21bb24 100644 --- a/eeschema/tools/sch_wire_bus_tool.cpp +++ b/eeschema/tools/sch_wire_bus_tool.cpp @@ -947,7 +947,7 @@ void SCH_WIRE_BUS_TOOL::finishSegments() } // Get the last non-null wire (this is the last created segment). - m_frame->SetRepeatItem( s_wires.GetLast() ); + m_frame->SaveCopyForRepeatItem( s_wires.GetLast()); // Add the new wires while( s_wires.GetFirst() )