diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index e874d5b8a2..3275be545b 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -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 ); } diff --git a/pcbnew/kicad_plugin.h b/pcbnew/kicad_plugin.h index c95459070c..497d4c392c 100644 --- a/pcbnew/kicad_plugin.h +++ b/pcbnew/kicad_plugin.h @@ -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 );