Fix segfault when not all libraries loaded.

Fixes: lp:1751464
* https://bugs.launchpad.net/kicad/+bug/1751464
This commit is contained in:
Jeff Young 2018-02-24 17:41:44 +00:00 committed by Wayne Stambaugh
parent baea3080ad
commit 9453a7e186
2 changed files with 29 additions and 12 deletions

View File

@ -247,7 +247,7 @@ void FP_CACHE::Save()
void FP_CACHE::Load()
{
{
wxDir dir( m_lib_path.GetPath() );
if( !dir.IsOpened() )
@ -1944,9 +1944,9 @@ void PCB_IO::init( const PROPERTIES* aProperties )
}
void PCB_IO::validateCache( const wxString& aLibraryPath )
void PCB_IO::validateCache( const wxString& aLibraryPath, bool checkModified )
{
if( !m_cache || m_cache->IsModified() )
if( !m_cache || ( checkModified && m_cache->IsModified() ) )
{
// a spectacular episode in memory management:
delete m_cache;
@ -1991,14 +1991,24 @@ void PCB_IO::FootprintEnumerate( wxArrayString& aFootprintNames,
}
MODULE* PCB_IO::LoadEnumeratedFootprint( const wxString& aLibraryPath,
const wxString& aFootprintName,
const PROPERTIES* aProperties )
MODULE* PCB_IO::doLoadFootprint( const wxString& aLibraryPath,
const wxString& aFootprintName,
const PROPERTIES* aProperties,
bool checkModified )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
init( aProperties );
try
{
validateCache( aLibraryPath, checkModified );
}
catch( const IO_ERROR& ioe )
{
// do nothing with the error
}
const MODULE_MAP& mods = m_cache->GetModules();
MODULE_CITER it = mods.find( aFootprintName );
@ -2013,14 +2023,18 @@ MODULE* PCB_IO::LoadEnumeratedFootprint( const wxString& aLibraryPath,
}
MODULE* PCB_IO::LoadEnumeratedFootprint( const wxString& aLibraryPath,
const wxString& aFootprintName,
const PROPERTIES* aProperties )
{
return doLoadFootprint( aLibraryPath, aFootprintName, aProperties, false );
}
MODULE* PCB_IO::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
const PROPERTIES* aProperties )
{
LOCALE_IO toggle; // toggles on, then off, the C locale.
validateCache( aLibraryPath );
return LoadEnumeratedFootprint( aLibraryPath, aFootprintName, aProperties );
return doLoadFootprint( aLibraryPath, aFootprintName, aProperties, true );
}

View File

@ -191,7 +191,10 @@ protected:
NETINFO_MAPPING* m_mapping; ///< mapping for net codes, so only not empty net codes
///< are stored with consecutive integers as net codes
void validateCache( const wxString& aLibraryPath );
void validateCache( const wxString& aLibraryPath, bool checkModified = true );
MODULE* doLoadFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
const PROPERTIES* aProperties, bool checkModified );
void init( const PROPERTIES* aProperties );