diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index a0910c3e60..9a3a9a9e8a 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -723,8 +723,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 diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index 80f894a789..8d5b01568f 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -1306,3 +1306,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; +} diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index 2aa39b5e68..9162a6b282 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -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; };