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.
This commit is contained in:
JamesJCode 2024-05-22 21:44:12 +01:00
parent 47e4ebb32a
commit 76cb7cf54a
2 changed files with 19 additions and 2 deletions

View File

@ -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<SCH_SYMBOL*>( 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<std::pair<SCH_SHEET_PATH, SCH_ITEM*>> 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;

View File

@ -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<CONNECTION_SUBGRAPH*> GetAllSubgraphs( const wxString& aNetName ) const;