From 76cb7cf54afb51f7c1aa780a0cbcdbac5733c753 Mon Sep 17 00:00:00 2001 From: JamesJCode <13408010-JamesJCode@users.noreply.gitlab.com> Date: Wed, 22 May 2024 21:44:12 +0100 Subject: [PATCH] Clear all dirty connectivity flags on symbols Fixes https://gitlab.com/kicad/code/kicad/-/issues/17984 When moving / deleting a power symbol, in some instances the symbol is marked dirty, and sometimes the pin (depending on whether the symbol is the primary edited item, or whether the pin is identified through an edited item subgraph). If the pin and the symbol are marked dirty, the pin dirty flag was not being cleared. Additionally, not all extracted items were being deleted from subgraphs correctly. Both resulted in dirty state and duplicated items in the subgraphs during incremental connectivity, which resulted in essentially corrupted subgraph states. --- eeschema/connection_graph.cpp | 19 ++++++++++++++++++- eeschema/connection_graph.h | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 59d467f0ce..ee8656bafb 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -754,6 +754,20 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco item->GetTypeDesc() ); items.push_back( item ); dirty_items.insert( item ); + + // Add any symbol dirty pins to the dirty_items list + if( item->Type() == SCH_SYMBOL_T ) + { + SCH_SYMBOL* symbol = static_cast( item ); + + for( SCH_PIN* pin : symbol->GetPins( &sheet ) ) + { + if( pin->IsConnectivityDirty() ) + { + dirty_items.insert( pin ); + } + } + } } // If the symbol isn't dirty, look at the pins // TODO: remove symbols from connectivity graph and only use pins @@ -937,6 +951,9 @@ std::set> CONNECTION_GRAPH::ExtractAffected removeSubgraphs( subgraphs ); + for( const auto& [path, item] : retvals ) + alg::delete_matching( m_items, item ); + return retvals; } @@ -3047,7 +3064,7 @@ CONNECTION_SUBGRAPH* CONNECTION_GRAPH::FindFirstSubgraphByName( const wxString& } -CONNECTION_SUBGRAPH* CONNECTION_GRAPH::GetSubgraphForItem( SCH_ITEM* aItem ) +CONNECTION_SUBGRAPH* CONNECTION_GRAPH::GetSubgraphForItem( SCH_ITEM* aItem ) const { auto it = m_item_to_subgraph_map.find( aItem ); CONNECTION_SUBGRAPH* ret = it != m_item_to_subgraph_map.end() ? it->second : nullptr; diff --git a/eeschema/connection_graph.h b/eeschema/connection_graph.h index 432decce99..bc25b95e44 100644 --- a/eeschema/connection_graph.h +++ b/eeschema/connection_graph.h @@ -434,7 +434,7 @@ public: */ CONNECTION_SUBGRAPH* FindFirstSubgraphByName( const wxString& aNetName ); - CONNECTION_SUBGRAPH* GetSubgraphForItem( SCH_ITEM* aItem ); + CONNECTION_SUBGRAPH* GetSubgraphForItem( SCH_ITEM* aItem ) const; const std::vector GetAllSubgraphs( const wxString& aNetName ) const;