Remove duplicate references from change symbol dialog.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15480

(cherry picked from commit 1db9febcfe)
This commit is contained in:
Wayne Stambaugh 2023-08-25 08:51:59 -04:00
parent 5b0d752e0c
commit aae7d94ffd
3 changed files with 23 additions and 0 deletions

View File

@ -720,8 +720,18 @@ wxString DIALOG_CHANGE_SYMBOLS::getSymbolReferences( SCH_SYMBOL& aSymbol, const
wxString references;
LIB_ID oldId = aSymbol.GetLibId();
SCH_EDIT_FRAME* parent = dynamic_cast< SCH_EDIT_FRAME* >( GetParent() );
wxCHECK( parent, msg );
SCH_SHEET_LIST sheets = parent->Schematic().GetSheets();
for( const SCH_SYMBOL_INSTANCE& instance : aSymbol.GetInstanceReferences() )
{
// Only include the symbol instances for the current project.
if( !sheets.HasPath( instance.m_Path ) )
continue;
if( references.IsEmpty() )
references = instance.m_Reference;
else

View File

@ -1302,3 +1302,14 @@ int SCH_SHEET_LIST::GetLastVirtualPageNumber() const
return lastVirtualPageNumber;
}
bool SCH_SHEET_LIST::HasPath( const KIID_PATH& aPath ) const
{
for( const SCH_SHEET_PATH& path : *this )
{
if( path.Path() == aPath )
return true;
}
return false;
}

View File

@ -672,6 +672,8 @@ public:
void RemoveSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPath );
bool HasPath( const KIID_PATH& aPath ) const;
private:
SCH_SHEET_PATH m_currentSheetPath;
};