From 89dff6411b3aa7f44a92a77c1abed29557748769 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 a21db33bdd..1620d53b0b 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -720,6 +720,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 @@ -890,6 +904,9 @@ std::set> CONNECTION_GRAPH::ExtractAffected removeSubgraphs( subgraphs ); + for( const auto& [path, item] : retvals ) + alg::delete_matching( m_items, item ); + return retvals; } @@ -2988,7 +3005,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 d930ab819b..a383fd42a1 100644 --- a/eeschema/connection_graph.h +++ b/eeschema/connection_graph.h @@ -428,7 +428,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;