Fix thread-safety issue with some global wxStrings.

These cause intermittent crashes in footprint loading.  See
comments in code.

(cherry picked from commit 5e8e2570ba)
This commit is contained in:
Jeff Young 2018-08-02 23:15:01 +01:00
parent 9d241ba812
commit 9230189f62
2 changed files with 63 additions and 59 deletions

View File

@ -68,40 +68,40 @@ static wxString FormatWildcardExt( const wxString& aWildcard )
} }
const wxString SchematicSymbolFileExtension( "sym" ); const std::string SchematicSymbolFileExtension( "sym" );
const wxString SchematicLibraryFileExtension( "lib" ); const std::string SchematicLibraryFileExtension( "lib" );
const wxString SchematicBackupFileExtension( "bak" ); const std::string SchematicBackupFileExtension( "bak" );
const wxString VrmlFileExtension( "wrl" ); const std::string VrmlFileExtension( "wrl" );
const wxString ProjectFileExtension( "pro" ); const std::string ProjectFileExtension( "pro" );
const wxString SchematicFileExtension( "sch" ); const std::string SchematicFileExtension( "sch" );
const wxString NetlistFileExtension( "net" ); const std::string NetlistFileExtension( "net" );
const wxString ComponentFileExtension( "cmp" ); const std::string ComponentFileExtension( "cmp" );
const wxString GerberFileExtension( "gbr" ); const std::string GerberFileExtension( "gbr" );
const wxString GerberJobFileExtension( "gbrjob" ); const std::string GerberJobFileExtension( "gbrjob" );
const wxString HtmlFileExtension( wxT( "html" ) ); const std::string HtmlFileExtension( "html" );
const wxString LegacyPcbFileExtension( "brd" ); const std::string LegacyPcbFileExtension( "brd" );
const wxString KiCadPcbFileExtension( "kicad_pcb" ); const std::string KiCadPcbFileExtension( "kicad_pcb" );
const wxString PageLayoutDescrFileExtension( "kicad_wks" ); const std::string PageLayoutDescrFileExtension( "kicad_wks" );
const wxString PdfFileExtension( "pdf" ); const std::string PdfFileExtension( "pdf" );
const wxString MacrosFileExtension( "mcr" ); const std::string MacrosFileExtension( "mcr" );
const wxString DrillFileExtension( "drl" ); const std::string DrillFileExtension( "drl" );
const wxString SVGFileExtension( "svg" ); const std::string SVGFileExtension( "svg" );
const wxString ReportFileExtension( "rpt" ); const std::string ReportFileExtension( "rpt" );
const wxString FootprintPlaceFileExtension( "pos" ); const std::string FootprintPlaceFileExtension( "pos" );
const wxString KiCadLib3DShapesPathExtension( "3dshapes" ); ///< 3D shapes default libpath const std::string KiCadLib3DShapesPathExtension( "3dshapes" ); ///< 3D shapes default libpath
const wxString KiCadFootprintLibPathExtension( "pretty" ); ///< KICAD PLUGIN libpath const std::string KiCadFootprintLibPathExtension( "pretty" ); ///< KICAD PLUGIN libpath
const wxString LegacyFootprintLibPathExtension( "mod" ); const std::string LegacyFootprintLibPathExtension( "mod" );
const wxString EagleFootprintLibPathExtension( "lbr" ); const std::string EagleFootprintLibPathExtension( "lbr" );
const wxString KiCadFootprintFileExtension( "kicad_mod" ); const std::string KiCadFootprintFileExtension( "kicad_mod" );
const wxString GedaPcbFootprintLibFileExtension( "fp" ); const std::string GedaPcbFootprintLibFileExtension( "fp" );
const wxString SpecctraDsnFileExtension( "dsn" ); const std::string SpecctraDsnFileExtension( "dsn" );
const wxString IpcD356FileExtension( "d356" ); const std::string IpcD356FileExtension( "d356" );
const wxString AllFilesWildcard( _( "All files (*)|*" ) ); const wxString AllFilesWildcard( _( "All files (*)|*" ) );

View File

@ -46,42 +46,44 @@
* @{ * @{
*/ */
extern const wxString AllFilesWildcard; // Do NOT use wxString for these. wxStrings are not thread-safe, even when const. (For the
// curious the UTF8 cacheing strategy puts iterators in a linked list. Insertion and removal
// from the linked list is not thread-safe.)
extern const wxString SchematicSymbolFileExtension; extern const std::string SchematicSymbolFileExtension;
extern const wxString SchematicLibraryFileExtension; extern const std::string SchematicLibraryFileExtension;
extern const wxString SchematicBackupFileExtension; extern const std::string SchematicBackupFileExtension;
extern const wxString VrmlFileExtension; extern const std::string VrmlFileExtension;
extern const wxString ProjectFileExtension; extern const std::string ProjectFileExtension;
extern const wxString SchematicFileExtension; extern const std::string SchematicFileExtension;
extern const wxString NetlistFileExtension; extern const std::string NetlistFileExtension;
extern const wxString GerberFileExtension; extern const std::string GerberFileExtension;
extern const wxString GerberJobFileExtension; extern const std::string GerberJobFileExtension;
extern const wxString HtmlFileExtension; extern const std::string HtmlFileExtension;
extern const wxString LegacyPcbFileExtension; extern const std::string LegacyPcbFileExtension;
extern const wxString KiCadPcbFileExtension; extern const std::string KiCadPcbFileExtension;
#define PcbFileExtension KiCadPcbFileExtension // symlink choice #define PcbFileExtension KiCadPcbFileExtension // symlink choice
extern const wxString PageLayoutDescrFileExtension; extern const std::string PageLayoutDescrFileExtension;
extern const wxString LegacyFootprintLibPathExtension; extern const std::string LegacyFootprintLibPathExtension;
extern const wxString PdfFileExtension; extern const std::string PdfFileExtension;
extern const wxString MacrosFileExtension; extern const std::string MacrosFileExtension;
extern const wxString ComponentFileExtension; extern const std::string ComponentFileExtension;
extern const wxString DrillFileExtension; extern const std::string DrillFileExtension;
extern const wxString SVGFileExtension; extern const std::string SVGFileExtension;
extern const wxString ReportFileExtension; extern const std::string ReportFileExtension;
extern const wxString FootprintPlaceFileExtension; extern const std::string FootprintPlaceFileExtension;
extern const wxString KiCadFootprintFileExtension; extern const std::string KiCadFootprintFileExtension;
extern const wxString KiCadFootprintLibPathExtension; extern const std::string KiCadFootprintLibPathExtension;
extern const wxString GedaPcbFootprintLibFileExtension; extern const std::string GedaPcbFootprintLibFileExtension;
extern const wxString EagleFootprintLibPathExtension; extern const std::string EagleFootprintLibPathExtension;
extern const wxString ComponentFileExtension; extern const std::string ComponentFileExtension;
extern const wxString PageLayoutDescrFileExtension; extern const std::string PageLayoutDescrFileExtension;
extern const wxString KiCadLib3DShapesPathExtension; extern const std::string KiCadLib3DShapesPathExtension;
extern const wxString SpecctraDsnFileExtension; extern const std::string SpecctraDsnFileExtension;
extern const wxString IpcD356FileExtension; extern const std::string IpcD356FileExtension;
/** /**
* @} * @}
@ -98,6 +100,8 @@ extern const wxString IpcD356FileExtension;
* @{ * @{
*/ */
extern const wxString AllFilesWildcard;
extern wxString ComponentFileWildcard(); extern wxString ComponentFileWildcard();
extern wxString PageLayoutDescrFileWildcard(); extern wxString PageLayoutDescrFileWildcard();
extern wxString SchematicSymbolFileWildcard(); extern wxString SchematicSymbolFileWildcard();