Workaround an issue where a throw terminates (even when there's a catch for it).
You can trigger it before this fix by running Cvpcb when a .kicad_mod file is incorrectly set as "Legacy" in your footprint table.
This commit is contained in:
parent
315a99e0fe
commit
e269b5d1b9
|
@ -259,11 +259,12 @@ long long FP_LIB_TABLE::GenerateTimestamp( const wxString* aNickname )
|
|||
}
|
||||
|
||||
|
||||
void FP_LIB_TABLE::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aNickname )
|
||||
void FP_LIB_TABLE::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aNickname,
|
||||
bool aBestEfforts )
|
||||
{
|
||||
const FP_LIB_TABLE_ROW* row = FindRow( aNickname );
|
||||
wxASSERT( (PLUGIN*) row->plugin );
|
||||
row->plugin->FootprintEnumerate( aFootprintNames, row->GetFullURI( true ),
|
||||
row->plugin->FootprintEnumerate( aFootprintNames, row->GetFullURI( true ), aBestEfforts,
|
||||
row->GetProperties() );
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ static int guessNickname( FP_LIB_TABLE* aTbl, LIB_ID* aFootprintId )
|
|||
{
|
||||
wxArrayString fpnames;
|
||||
|
||||
aTbl->FootprintEnumerate( fpnames, nicks[libNdx] );
|
||||
aTbl->FootprintEnumerate( fpnames, nicks[libNdx], true );
|
||||
|
||||
for( unsigned nameNdx = 0; nameNdx<fpnames.size(); ++nameNdx )
|
||||
{
|
||||
|
|
|
@ -147,10 +147,12 @@ public:
|
|||
* @param aFootprintNames is the list to fill with the footprint names found in \a aNickname
|
||||
*
|
||||
* @param aNickname is a locator for the "library", it is a "name" in LIB_TABLE_ROW.
|
||||
* @param aBestEfforts if true, don't throw on errors
|
||||
*
|
||||
* @throw IO_ERROR if the library cannot be found, or footprint cannot be loaded.
|
||||
*/
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aNickname );
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aNickname,
|
||||
bool aBestEfforts );
|
||||
|
||||
/**
|
||||
* Generate a hashed timestamp representing the last-mod-times of the library indicated
|
||||
|
|
|
@ -2486,14 +2486,29 @@ void EAGLE_PLUGIN::cacheLib( const wxString& aLibPath )
|
|||
|
||||
|
||||
void EAGLE_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties )
|
||||
bool aBestEfforts, const PROPERTIES* aProperties )
|
||||
{
|
||||
wxString errorMsg;
|
||||
|
||||
init( aProperties );
|
||||
|
||||
cacheLib( aLibraryPath );
|
||||
try
|
||||
{
|
||||
cacheLib( aLibraryPath );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
errorMsg = ioe.What();
|
||||
}
|
||||
|
||||
// Some of the files may have been parsed correctly so we want to add the valid files to
|
||||
// the library.
|
||||
|
||||
for( MODULE_CITER it = m_templates.begin(); it != m_templates.end(); ++it )
|
||||
aFootprintNames.Add( FROM_UTF8( it->first.c_str() ) );
|
||||
|
||||
if( !errorMsg.IsEmpty() && !aBestEfforts )
|
||||
THROW_IO_ERROR( errorMsg );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ public:
|
|||
const wxString GetFileExtension() const override;
|
||||
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = NULL) override;
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = NULL) override;
|
||||
|
||||
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
|
|
|
@ -261,7 +261,7 @@ bool FOOTPRINT_LIST_IMPL::JoinWorkers()
|
|||
|
||||
try
|
||||
{
|
||||
m_lib_table->FootprintEnumerate( fpnames, nickname );
|
||||
m_lib_table->FootprintEnumerate( fpnames, nickname, false );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
|
|
|
@ -138,34 +138,38 @@ const wxString GITHUB_PLUGIN::GetFileExtension() const
|
|||
}
|
||||
|
||||
|
||||
void GITHUB_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames,
|
||||
const wxString& aLibraryPath, const PROPERTIES* aProperties )
|
||||
void GITHUB_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibPath,
|
||||
bool aBestEfforts, const PROPERTIES* aProperties )
|
||||
{
|
||||
//D(printf("%s: this:%p aLibraryPath:\"%s\"\n", __func__, this, TO_UTF8(aLibraryPath) );)
|
||||
cacheLib( aLibraryPath, aProperties );
|
||||
|
||||
typedef std::set<wxString> MYSET;
|
||||
|
||||
MYSET unique;
|
||||
|
||||
if( m_pretty_dir.size() )
|
||||
try
|
||||
{
|
||||
wxArrayString locals;
|
||||
//D(printf("%s: this:%p aLibPath:\"%s\"\n", __func__, this, TO_UTF8(aLibraryPath) );)
|
||||
cacheLib( aLibPath, aProperties );
|
||||
|
||||
PCB_IO::FootprintEnumerate( locals, m_pretty_dir );
|
||||
typedef std::set<wxString> MYSET;
|
||||
|
||||
for( unsigned i=0; i<locals.GetCount(); ++i )
|
||||
unique.insert( locals[i] );
|
||||
MYSET unique;
|
||||
|
||||
if( m_pretty_dir.size() )
|
||||
{
|
||||
wxArrayString locals;
|
||||
|
||||
PCB_IO::FootprintEnumerate( locals, m_pretty_dir, aBestEfforts );
|
||||
|
||||
for( unsigned i=0; i<locals.GetCount(); ++i )
|
||||
unique.insert( locals[i] );
|
||||
}
|
||||
|
||||
for( MODULE_ITER it = m_gh_cache->begin(); it!=m_gh_cache->end(); ++it )
|
||||
unique.insert( it->first );
|
||||
|
||||
for( MYSET::const_iterator it = unique.begin(); it != unique.end(); ++it )
|
||||
aFootprintNames.Add( *it );
|
||||
}
|
||||
|
||||
for( MODULE_ITER it = m_gh_cache->begin(); it!=m_gh_cache->end(); ++it )
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
unique.insert( it->first );
|
||||
}
|
||||
|
||||
for( MYSET::const_iterator it = unique.begin(); it != unique.end(); ++it )
|
||||
{
|
||||
aFootprintNames.Add( *it );
|
||||
if( !aBestEfforts )
|
||||
throw ioe;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,20 +167,20 @@ public:
|
|||
|
||||
const wxString GetFileExtension() const override;
|
||||
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibPath,
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
void PrefetchLib( const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
MODULE* FootprintLoad( const wxString& aLibraryPath,
|
||||
const wxString& aFootprintName, const PROPERTIES* aProperties ) override;
|
||||
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties ) override;
|
||||
|
||||
void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
|
||||
|
||||
|
|
|
@ -867,25 +867,26 @@ void GPCB_PLUGIN::validateCache( const wxString& aLibraryPath, bool checkModifie
|
|||
}
|
||||
|
||||
|
||||
void GPCB_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames,
|
||||
const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties )
|
||||
void GPCB_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
bool aBestEfforts, const PROPERTIES* aProperties )
|
||||
{
|
||||
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||
wxDir dir( aLibraryPath );
|
||||
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||
wxDir dir( aLibraryPath );
|
||||
wxString errorMsg;
|
||||
|
||||
if( !dir.IsOpened() )
|
||||
{
|
||||
THROW_IO_ERROR( wxString::Format( _( "footprint library path \"%s\" does not exist" ),
|
||||
GetChars( aLibraryPath ) ) );
|
||||
if( aBestEfforts )
|
||||
return;
|
||||
else
|
||||
{
|
||||
THROW_IO_ERROR( wxString::Format( _( "footprint library path \"%s\" does not exist" ),
|
||||
aLibraryPath ) );
|
||||
}
|
||||
}
|
||||
|
||||
init( aProperties );
|
||||
|
||||
wxString errorMsg;
|
||||
|
||||
// Some of the files may have been parsed correctly so we want to add the valid files to
|
||||
// the library.
|
||||
try
|
||||
{
|
||||
validateCache( aLibraryPath );
|
||||
|
@ -895,14 +896,13 @@ void GPCB_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames,
|
|||
errorMsg = ioe.What();
|
||||
}
|
||||
|
||||
const MODULE_MAP& mods = m_cache->GetModules();
|
||||
// Some of the files may have been parsed correctly so we want to add the valid files to
|
||||
// the library.
|
||||
|
||||
for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it )
|
||||
{
|
||||
for( MODULE_CITER it = m_cache->GetModules().begin(); it != m_cache->GetModules().end(); ++it )
|
||||
aFootprintNames.Add( FROM_UTF8( it->first.c_str() ) );
|
||||
}
|
||||
|
||||
if( !errorMsg.IsEmpty() )
|
||||
if( !errorMsg.IsEmpty() && !aBestEfforts )
|
||||
THROW_IO_ERROR( errorMsg );
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
}
|
||||
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = NULL) override;
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
const MODULE* GetEnumeratedFootprint( const wxString& aLibraryPath,
|
||||
const wxString& aFootprintName,
|
||||
|
|
|
@ -353,10 +353,12 @@ public:
|
|||
*
|
||||
* @param aFootprintNames is the array of available footprint names inside a library.
|
||||
*
|
||||
* @param aBestEfforts if true, don't throw on errors, just return an empty list.
|
||||
*
|
||||
* @throw IO_ERROR if the library cannot be found, or footprint cannot be loaded.
|
||||
*/
|
||||
virtual void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = NULL );
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = NULL );
|
||||
|
||||
/**
|
||||
* Generate a timestamp representing all the files in the library (including the library
|
||||
|
|
|
@ -2028,20 +2028,18 @@ void PCB_IO::validateCache( const wxString& aLibraryPath, bool checkModified )
|
|||
}
|
||||
|
||||
|
||||
void PCB_IO::FootprintEnumerate( wxArrayString& aFootprintNames,
|
||||
const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties )
|
||||
void PCB_IO::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibPath,
|
||||
bool aBestEfforts, const PROPERTIES* aProperties )
|
||||
{
|
||||
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||
wxDir dir( aLibraryPath );
|
||||
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||
wxDir dir( aLibPath );
|
||||
wxString errorMsg;
|
||||
|
||||
init( aProperties );
|
||||
|
||||
wxString errorMsg;
|
||||
|
||||
try
|
||||
{
|
||||
validateCache( aLibraryPath );
|
||||
validateCache( aLibPath );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
|
@ -2051,14 +2049,10 @@ void PCB_IO::FootprintEnumerate( wxArrayString& aFootprintNames,
|
|||
// Some of the files may have been parsed correctly so we want to add the valid files to
|
||||
// the library.
|
||||
|
||||
const MODULE_MAP& mods = m_cache->GetModules();
|
||||
|
||||
for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it )
|
||||
{
|
||||
for( MODULE_CITER it = m_cache->GetModules().begin(); it != m_cache->GetModules().end(); ++it )
|
||||
aFootprintNames.Add( it->first );
|
||||
}
|
||||
|
||||
if( !errorMsg.IsEmpty() )
|
||||
if( !errorMsg.IsEmpty() && !aBestEfforts )
|
||||
THROW_IO_ERROR( errorMsg );
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
const MODULE* GetEnumeratedFootprint( const wxString& aLibraryPath,
|
||||
const wxString& aFootprintName,
|
||||
|
|
|
@ -3269,10 +3269,10 @@ void LP_CACHE::ReadAndVerifyHeader( LINE_READER* aReader )
|
|||
char* saveptr;
|
||||
|
||||
if( !line )
|
||||
goto L_bad_library;
|
||||
THROW_IO_ERROR( wxString::Format( _( "File '%s' is empty." ), m_lib_path ) );
|
||||
|
||||
if( !TESTLINE( "PCBNEW-LibModule-V1" ) )
|
||||
goto L_bad_library;
|
||||
THROW_IO_ERROR( wxString::Format( _( "File '%s' is not a legacy library." ), m_lib_path ) );
|
||||
|
||||
while( ( line = aReader->ReadLine() ) != NULL )
|
||||
{
|
||||
|
@ -3281,18 +3281,12 @@ void LP_CACHE::ReadAndVerifyHeader( LINE_READER* aReader )
|
|||
const char* units = strtok_r( line + SZ( "Units" ), delims, &saveptr );
|
||||
|
||||
if( !strcmp( units, "mm" ) )
|
||||
{
|
||||
m_owner->diskToBiu = IU_PER_MM;
|
||||
}
|
||||
|
||||
}
|
||||
else if( TESTLINE( "$INDEX" ) )
|
||||
return;
|
||||
}
|
||||
|
||||
L_bad_library:
|
||||
THROW_IO_ERROR( wxString::Format( _( "File \"%s\" is empty or is not a legacy library" ),
|
||||
m_lib_path.GetData() ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -3432,22 +3426,31 @@ void LEGACY_PLUGIN::cacheLib( const wxString& aLibraryPath )
|
|||
}
|
||||
|
||||
|
||||
void LEGACY_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames,
|
||||
const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties )
|
||||
void LEGACY_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibPath,
|
||||
bool aBestEfforts, const PROPERTIES* aProperties )
|
||||
{
|
||||
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||
LOCALE_IO toggle; // toggles on, then off, the C locale.
|
||||
wxString errorMsg;
|
||||
|
||||
init( aProperties );
|
||||
|
||||
cacheLib( aLibraryPath );
|
||||
|
||||
const MODULE_MAP& mods = m_cache->m_modules;
|
||||
|
||||
for( MODULE_CITER it = mods.begin(); it != mods.end(); ++it )
|
||||
try
|
||||
{
|
||||
aFootprintNames.Add( FROM_UTF8( it->first.c_str() ) );
|
||||
cacheLib( aLibPath );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
errorMsg = ioe.What();
|
||||
}
|
||||
|
||||
// Some of the files may have been parsed correctly so we want to add the valid files to
|
||||
// the library.
|
||||
|
||||
for( MODULE_CITER it = m_cache->m_modules.begin(); it != m_cache->m_modules.end(); ++it )
|
||||
aFootprintNames.Add( FROM_UTF8( it->first.c_str() ) );
|
||||
|
||||
if( !errorMsg.IsEmpty() && !aBestEfforts )
|
||||
THROW_IO_ERROR( errorMsg );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
bool aBestEfforts, const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
||||
const PROPERTIES* aProperties = NULL ) override;
|
||||
|
|
|
@ -401,7 +401,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveLibraryAs( const wxString& aLibraryPath )
|
|||
|
||||
wxArrayString footprints;
|
||||
|
||||
cur->FootprintEnumerate( footprints, curLibPath );
|
||||
cur->FootprintEnumerate( footprints, curLibPath, false );
|
||||
|
||||
for( unsigned i = 0; i < footprints.size(); ++i )
|
||||
{
|
||||
|
|
|
@ -58,7 +58,7 @@ void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* a
|
|||
|
||||
|
||||
void PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||
const PROPERTIES* aProperties )
|
||||
bool aBestEfforts, const PROPERTIES* aProperties )
|
||||
{
|
||||
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
|
||||
not_implemented( this, __FUNCTION__ );
|
||||
|
|
|
@ -73,18 +73,7 @@
|
|||
{
|
||||
wxArrayString footprintNames;
|
||||
|
||||
if( aExitOnError )
|
||||
self->FootprintEnumerate( footprintNames, aLibraryPath );
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
self->FootprintEnumerate( footprintNames, aLibraryPath );
|
||||
}
|
||||
catch( const IO_ERROR& error )
|
||||
{
|
||||
}
|
||||
}
|
||||
self->FootprintEnumerate( footprintNames, aLibraryPath, !aExitOnError );
|
||||
|
||||
return footprintNames;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue