diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index 6aba27f8eb..c31b24fbff 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -400,10 +400,7 @@ void DIALOG_CHANGE_SYMBOLS::onOkButtonClicked( wxCommandEvent& aEvent ) } if( processMatchingSymbols( &commit) ) - { - parent->TestDanglingEnds(); // This will also redraw the changed symbols. commit.Push( m_mode == MODE::CHANGE ? _( "Change Symbols" ) : _( "Update Symbols" ) ); - } m_messagePanel->Flush( false ); } diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index 46ec1a1426..df49989e04 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -866,7 +866,6 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow() } currentScreen->Append( m_symbol ); - GetParent()->TestDanglingEnds(); GetParent()->UpdateItem( m_symbol, false, true ); if( !commit.Empty() ) diff --git a/eeschema/picksymbol.cpp b/eeschema/picksymbol.cpp index 209127b96f..d64031266d 100644 --- a/eeschema/picksymbol.cpp +++ b/eeschema/picksymbol.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2023 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 @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include @@ -240,6 +240,7 @@ PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibTree( const SYMBOL_LIBRARY_FILTER void SCH_EDIT_FRAME::SelectUnit( SCH_SYMBOL* aSymbol, int aUnit ) { + SCH_COMMIT commit( m_toolManager ); LIB_SYMBOL* symbol = GetLibSymbol( aSymbol->GetLibId() ); if( !symbol ) @@ -253,26 +254,20 @@ void SCH_EDIT_FRAME::SelectUnit( SCH_SYMBOL* aSymbol, int aUnit ) if( aUnit > unitCount ) aUnit = unitCount; - EDA_ITEM_FLAGS savedFlags = aSymbol->GetFlags(); - if( !aSymbol->GetEditFlags() ) // No command in progress: save in undo list - SaveCopyInUndoList( GetScreen(), aSymbol, UNDO_REDO::CHANGED, false ); + commit.Modify( aSymbol, GetScreen() ); /* Update the unit number. */ aSymbol->SetUnitSelection( &GetCurrentSheet(), aUnit ); aSymbol->SetUnit( aUnit ); - aSymbol->ClearFlags(); - aSymbol->SetFlags( savedFlags ); // Restore m_Flag modified by SetUnit() - if( !aSymbol->GetEditFlags() ) // No command in progress: update schematic + if( !commit.Empty() ) { if( eeconfig()->m_AutoplaceFields.enable ) aSymbol->AutoAutoplaceFields( GetScreen() ); - TestDanglingEnds(); - UpdateItem( aSymbol, false, true ); - OnModify(); + commit.Push( _( "Change Unit" ) ); } } @@ -282,7 +277,8 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_SYMBOL* aSymbol ) if( !aSymbol || !aSymbol->GetLibSymbolRef() ) return; - wxString msg; + SCH_COMMIT commit( m_toolManager ); + wxString msg; if( !aSymbol->GetLibSymbolRef()->HasConversion() ) { @@ -295,7 +291,7 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_SYMBOL* aSymbol ) return; } - EDA_ITEM_FLAGS savedFlags = aSymbol->GetFlags(); + commit.Modify( aSymbol, GetScreen() ); aSymbol->SetConvert( aSymbol->GetConvert() + 1 ); @@ -307,14 +303,10 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_SYMBOL* aSymbol ) if( aSymbol->GetConvert() > LIB_ITEM::LIB_CONVERT::DEMORGAN ) aSymbol->SetConvert( LIB_ITEM::LIB_CONVERT::BASE ); - TestDanglingEnds(); - aSymbol->ClearFlags(); - aSymbol->SetFlags( savedFlags ); // Restore m_flags (modified by SetConvert()) - // If selected make sure all the now-included pins are selected if( aSymbol->IsSelected() ) m_toolManager->RunAction( EE_ACTIONS::addItemToSel, true, aSymbol ); UpdateItem( aSymbol, false, true ); - OnModify(); + commit.Push( _( "Convert Symbol" ) ); } diff --git a/eeschema/sch_commit.cpp b/eeschema/sch_commit.cpp index abbf04a2aa..750a6969ee 100644 --- a/eeschema/sch_commit.cpp +++ b/eeschema/sch_commit.cpp @@ -347,6 +347,9 @@ void SCH_COMMIT::pushSchEdit( const wxString& aMessage, int aCommitFlags ) if( selectedModified ) m_toolMgr->ProcessEvent( EVENTS::SelectedItemsModified ); + if( frame ) + frame->TestDanglingEnds(); + if( !( aCommitFlags & SKIP_SET_DIRTY ) ) { if( frame ) @@ -499,6 +502,8 @@ void SCH_COMMIT::Revert() if( view ) view->Add( item ); + screen->Update( item ); + delete copy; break; } @@ -525,7 +530,10 @@ void SCH_COMMIT::Revert() selTool->RebuildSelection(); if( frame ) + { frame->RecalculateConnections( nullptr, NO_CLEANUP ); + frame->TestDanglingEnds(); + } clear(); } diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 0046570c63..61793ca317 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -70,14 +70,6 @@ std::string toUTFTildaText( const wxString& txt ) * Used to draw a dummy shape when a LIB_SYMBOL is not found in library * * This symbol is a 400 mils square with the text "??" - * DEF DUMMY U 0 40 Y Y 1 0 N - * F0 "U" 0 -350 60 H V - * F1 "DUMMY" 0 350 60 H V - * DRAW - * T 0 0 0 150 0 0 0 ?? - * S -200 200 200 -200 0 1 0 - * ENDDRAW - * ENDDEF */ static LIB_SYMBOL* dummy() { @@ -387,11 +379,7 @@ void SCH_SYMBOL::UpdatePins() void SCH_SYMBOL::SetUnit( int aUnit ) { - if( m_unit != aUnit ) - { - UpdateUnit( aUnit ); - SetModified(); - } + UpdateUnit( aUnit ); } @@ -409,7 +397,6 @@ void SCH_SYMBOL::SetConvert( int aConvert ) // The convert may have a different pin layout so the update the pin map. UpdatePins(); - SetModified(); } } @@ -417,10 +404,7 @@ void SCH_SYMBOL::SetConvert( int aConvert ) void SCH_SYMBOL::SetTransform( const TRANSFORM& aTransform ) { if( m_transform != aTransform ) - { m_transform = aTransform; - SetModified(); - } } diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 24f084c222..92ca1af033 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -851,10 +851,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent ) SCH_COMMIT commit( m_toolMgr ); commit.Add( newItem, screen ); - if( type == SCH_JUNCTION_T ) - m_frame->TestDanglingEnds(); - else - m_frame->SchematicCleanUp( &commit ); + m_frame->SchematicCleanUp( &commit ); commit.Push( description ); } diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 7c4a507828..9bcd993259 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -923,7 +923,6 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) lwbTool->AddJunctionsIfNeeded( commit, &selectionCopy ); m_frame->SchematicCleanUp( commit ); - m_frame->TestDanglingEnds(); if( !localCommit.Empty() ) localCommit.Push( _( "Rotate" ) ); @@ -1121,7 +1120,6 @@ int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) lwbTool->AddJunctionsIfNeeded( commit, &selectionCopy ); m_frame->SchematicCleanUp( commit ); - m_frame->TestDanglingEnds(); } if( !localCommit.Empty() ) @@ -1311,7 +1309,6 @@ int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent ) lwbTool->AddJunctionsIfNeeded( &commit, &newItems ); m_frame->SchematicCleanUp( &commit ); - m_frame->TestDanglingEnds(); } m_frame->GetCanvas()->Refresh(); diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index 0c6ce0ff83..6dc8833c95 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -1223,7 +1223,6 @@ void SCH_LINE_WIRE_BUS_TOOL::finishSegments() for( SCH_ITEM* item : m_frame->GetScreen()->Items() ) item->ClearEditFlags(); - m_frame->TestDanglingEnds(); commit.Push( _( "Draw Wires" ) ); } diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 5626ceea48..fa2a5ed8ee 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -1756,7 +1756,6 @@ int SCH_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent ) m_toolMgr->PostEvent( EVENTS::SelectedItemsMoved ); m_frame->SchematicCleanUp( &commit ); - m_frame->TestDanglingEnds(); commit.Push( _( "Align" ) ); return 0;