From ebfbbcc1f5e7ad7a08b0af017bb3556a0a5a25c7 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sat, 28 Jan 2017 16:59:09 -0500 Subject: [PATCH] Fix missing part library broken by schematic I/O plugin changes. The LIB_PART object stores a pointer to the PART_LIB that it belongs to. Now that the PART_LIB is no long responsible for loading the library, add the PART_LIB pointer after the library is loaded by the plugin. --- eeschema/class_library.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index f04203dd99..4fb7e2a318 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -302,10 +302,20 @@ PART_LIB* PART_LIB::LoadLibrary( const wxString& aFileName ) throw( IO_ERROR, bo wxArrayString tmp; // This loads the library although we could probably do lazy loading. - lib->GetCount(); + lib->GetAliasNames( tmp ); + + // This not them most efficient way to set the LIB_PART m_library member but it will + // only be used when loading legacy libraries in the future. Once the symbols in the + // schematic have a full #LIB_ID, this will not get called. + for( size_t i = 0; i < tmp.GetCount(); i++ ) + { + LIB_ALIAS* alias = lib->FindAlias( tmp[i] ); + + if( alias && alias->GetPart() ) + alias->GetPart()->SetLib( lib.get() ); + } PART_LIB* ret = lib.release(); - return ret; }