Eeschema: fix symbol cache library look up bug.

Use an underscore character instead of a semicolon between the library
ID library nickname and symbol name in library ID search strings when
looking up symbols in the cache library since that is how they are saved
when creating the cache library.  This fixes rescuing missing symbols
from the cache when they have been removed from the original library and
preventing a broken symbol link indicator from being shown when a symbol
is removed from the library.

Add some defensive testing to make sure the library passed to function
SchGetLibPart() is actually the cache library.
This commit is contained in:
Wayne Stambaugh 2020-04-02 15:24:28 -04:00
parent 23c1baae8e
commit f6d7ef367d
1 changed files with 11 additions and 6 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015-2019 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2015-2020 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -48,17 +48,22 @@
LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, PART_LIB* aCacheLib,
wxWindow* aParent, bool aShowErrorMsg )
{
// wxCHECK_MSG( aLibId.IsValid(), NULL, "LIB_ID is not valid." );
wxCHECK_MSG( aLibTable, NULL, "Invalid symbol library table." );
wxCHECK_MSG( aLibTable, nullptr, "Invalid symbol library table." );
LIB_PART* symbol = NULL;
LIB_PART* symbol = nullptr;
try
{
symbol = aLibTable->LoadSymbol( aLibId );
if( !symbol && aCacheLib )
symbol = aCacheLib->FindPart( aLibId );
{
wxCHECK_MSG( aCacheLib->IsCache(), nullptr, "Invalid cache library." );
wxString cacheName = aLibId.GetLibNickname().wx_str();
cacheName += "_" + aLibId.GetLibItemName();
symbol = aCacheLib->FindPart( cacheName );
}
}
catch( const IO_ERROR& ioe )
{
@ -506,4 +511,4 @@ COLOR_SETTINGS* SCH_BASE_FRAME::GetColorSettings()
}
return m_colorSettings;
}
}