From 6e65049a56c989f5c4412f25a4f1aea1fcbfb8ba Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 9 Jan 2018 13:26:31 +0100 Subject: [PATCH] Do not modify LIB_ID in LIB_PART::SetLib() This commit is a partial revert of aa81f5b9 & 445ac505. LIB_ID should not be modified when a library is assigned to its part, as the library nickname cannot be evaluated during the assignment and might be different than its filename. --- eeschema/class_libentry.cpp | 9 --------- eeschema/class_libentry.h | 3 ++- eeschema/project_rescue.cpp | 1 + eeschema/sch_legacy_plugin.cpp | 3 +++ 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 31ef736eb5..434af86282 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -1203,15 +1203,6 @@ void LIB_PART::SetConversion( bool aSetConvert ) } -void LIB_PART::SetLib( PART_LIB* aLibrary ) -{ - m_library = aLibrary; - - if( aLibrary ) - m_libId.SetLibNickname( aLibrary->GetName() ); -} - - wxArrayString LIB_PART::GetAliasNames( bool aIncludeRoot ) const { wxArrayString names; diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 37215f6f7f..af546123e6 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -265,12 +265,13 @@ public: const wxString& GetName() const; const LIB_ID& GetLibId() const { return m_libId; } + void SetLibId( const LIB_ID& aLibId ) { m_libId = aLibId; } const wxString GetLibraryName(); PART_LIB* GetLib() { return m_library; } - void SetLib( PART_LIB* aLibrary ); + void SetLib( PART_LIB* aLibrary ) { m_library = aLibrary; } wxArrayString GetAliasNames( bool aIncludeRoot = true ) const; diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index 0e78f98195..9bd8a7f2b9 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -437,6 +437,7 @@ bool RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::PerformAction( RESCUER* aRescuer ) wxCHECK_MSG( tmp, false, "Both cache and library symbols undefined." ); LIB_PART new_part( *tmp ); + new_part.SetLibId( m_new_id ); new_part.SetName( m_new_id.GetLibItemName() ); new_part.RemoveAllAliases(); aRescuer->AddPart( &new_part ); diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 19aa0f6553..5b5d88a25a 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -2515,6 +2515,9 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::loadPart( FILE_LINE_READER& aReader ) part->GetValueField().SetVisible( false ); } + // Don't set the library alias, this is determined by the symbol library table. + part->SetLibId( LIB_ID( wxEmptyString, part->GetName() ) ); + // There are some code paths in SetText() that do not set the root alias to the // alias list so add it here if it didn't get added by SetText(). if( !part->HasAlias( part->GetName() ) )