diff --git a/common/common.cpp b/common/common.cpp index be344278a3..f23d111b09 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -120,15 +120,17 @@ StructColors ColorRefs[NBCOLOR] = bool g_DisableFloatingPointLocalNotation = false; -void SetLocaleTo_C_standard( void ) +int LOCALE_IO::C_count; + + +void SetLocaleTo_C_standard() { setlocale( LC_NUMERIC, "C" ); // Switch the locale to standard C } - -void SetLocaleTo_Default( void ) +void SetLocaleTo_Default() { - if( ! g_DisableFloatingPointLocalNotation ) + if( !g_DisableFloatingPointLocalNotation ) setlocale( LC_NUMERIC, "" ); // revert to the current locale } diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index a8af4e515d..9b0602e25d 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -16,8 +16,6 @@ #include #include -#include -#include #include #include @@ -42,57 +40,68 @@ */ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) { - wxFileName filename; - wxString libname; - // Clear data before reading files m_filesNotFound.Empty(); m_filesInvalid.Empty(); m_List.clear(); - PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) ); - - // Parse Libraries Listed - for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ ) + // try { - filename = aFootprintsLibNames[ii]; - filename.SetExt( FootprintLibFileExtension ); + PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) ); - libname = wxGetApp().FindLibraryPath( filename ); - - if( libname.IsEmpty() ) + // Parse Libraries Listed + for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ ) { - m_filesNotFound << filename.GetFullName() << wxT("\n"); - continue; - } + wxFileName filename = aFootprintsLibNames[ii]; - try - { - wxArrayString fpnames = pi->FootprintEnumerate( libname ); + filename.SetExt( FootprintLibFileExtension ); - for( unsigned i=0; i m( pi->FootprintLoad( libname, fpnames[i] ) ); + m_filesNotFound << filename.GetFullName() << wxT("\n"); + continue; + } - FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO(); + try + { + wxArrayString fpnames = pi->FootprintEnumerate( libPath ); - fpinfo->m_Module = fpnames[i]; - fpinfo->m_LibName = libname; - fpinfo->m_padCount = m->GetPadCount(); - fpinfo->m_KeyWord = m->GetKeywords(); - fpinfo->m_Doc = m->GetDescription(); + for( unsigned i=0; i m( pi->FootprintLoad( libPath, fpnames[i] ) ); - AddItem( fpinfo ); + // we're loading what we enumerated, all must be there. + wxASSERT( m.get() ); + + FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO(); + + fpinfo->m_Module = fpnames[i]; + fpinfo->m_LibName = libPath; + fpinfo->m_padCount = m->GetPadCount(); + fpinfo->m_KeyWord = m->GetKeywords(); + fpinfo->m_Doc = m->GetDescription(); + + AddItem( fpinfo ); + } + } + catch( IO_ERROR ioe ) + { + m_filesInvalid << ioe.errorText << wxT("\n"); } } - catch( IO_ERROR ioe ) - { - m_filesInvalid << ioe.errorText << wxT("\n"); - } } + /* caller should catch this, UI seems not wanted here. + catch( IO_ERROR ioe ) + { + DisplayError( NULL, ioe.errorText ); + return false; + } + */ + m_List.sort(); return true; } - diff --git a/include/common.h b/include/common.h index 4e10dc5f0e..12d8efe3f7 100644 --- a/include/common.h +++ b/include/common.h @@ -454,6 +454,7 @@ void SetLocaleTo_C_standard(); */ void SetLocaleTo_Default(); + /** * Class LOCALE_IO * is a class that can be instantiated within a scope in which you are expecting @@ -464,10 +465,23 @@ void SetLocaleTo_Default(); class LOCALE_IO { public: - LOCALE_IO() { SetLocaleTo_C_standard(); } - ~LOCALE_IO() { SetLocaleTo_Default(); } + LOCALE_IO() + { + if( C_count++ == 0 ) + SetLocaleTo_C_standard(); + } + + ~LOCALE_IO() + { + if( --C_count == 0 ) + SetLocaleTo_Default(); + } + +private: + static int C_count; // allow for nesting of LOCALE_IO instantiations }; + /** * Function EnsureTextCtrlWidth * sets the minimum pixel width on a text control in order to make a text diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 81ffe64e71..52476367ac 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -4186,6 +4186,17 @@ bool LEGACY_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath ) } +LEGACY_PLUGIN::LEGACY_PLUGIN() : + m_board( 0 ), + m_props( 0 ), + m_reader( 0 ), + m_fp( 0 ), + m_cache( 0 ) +{ + init( NULL ); +} + + LEGACY_PLUGIN::~LEGACY_PLUGIN() { delete m_cache; diff --git a/pcbnew/legacy_plugin.h b/pcbnew/legacy_plugin.h index ae19e59ede..c62201c120 100644 --- a/pcbnew/legacy_plugin.h +++ b/pcbnew/legacy_plugin.h @@ -55,7 +55,7 @@ struct FPL_CACHE; /** * Class LEGACY_PLUGIN * is a PLUGIN derivation which could possibly be put into a DLL/DSO. - * It is not thread safe, but it is re-entrant multiple times in sequence. + * As with any PLUGIN, there is no UI, i.e. windowing calls allowed. */ class LEGACY_PLUGIN : public PLUGIN { @@ -99,14 +99,7 @@ public: //-------------------------------------------------- - LEGACY_PLUGIN() : - m_board( 0 ), - m_props( 0 ), - m_reader( 0 ), - m_fp( 0 ), - m_cache( 0 ) - {} - + LEGACY_PLUGIN(); ~LEGACY_PLUGIN(); void SetReader( LINE_READER* aReader ) { m_reader = aReader; }