From b4fc78fc0d6c889e8573396c0bbae00e47b2f688 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 19 Jul 2019 18:15:23 +0200 Subject: [PATCH] kicad_plugin.cpp: fix incorrect detection of existing footprints in PCB_IO::FootprintExists(), when fp names contain a point. Fixes: lp:1837221 https://bugs.launchpad.net/kicad/+bug/1837221 --- pcbnew/kicad_plugin.cpp | 6 +++--- pcbnew/tools/footprint_editor_tools.cpp | 8 ++++---- pcbnew/tools/pcbnew_picker_tool.h | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index a2e7eefbe6..cf4b6c7998 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -2108,9 +2108,9 @@ bool PCB_IO::FootprintExists( const wxString& aLibraryPath, const wxString& aFoo // // Since this goes out to the native filesystem, we get platform differences (ie: MSW's // case-insensitive filesystem) handled "for free". - - wxFileName footprintFile( aLibraryPath, aFootprintName ); - footprintFile.SetExt( KiCadFootprintFileExtension ); + // Warning: footprint names frequently contain a point. So be careful when initializing + // wxFileName, and use a CTOR with extension specified + wxFileName footprintFile( aLibraryPath, aFootprintName, KiCadFootprintFileExtension ); return footprintFile.Exists(); } diff --git a/pcbnew/tools/footprint_editor_tools.cpp b/pcbnew/tools/footprint_editor_tools.cpp index 59936a81c6..8f86f7c1a7 100644 --- a/pcbnew/tools/footprint_editor_tools.cpp +++ b/pcbnew/tools/footprint_editor_tools.cpp @@ -114,7 +114,7 @@ bool MODULE_EDITOR_TOOLS::Init() ctxMenu.AddSeparator(); ctxMenu.AddItem( PCB_ACTIONS::importFootprint, SELECTION_CONDITIONS::ShowAlways ); ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpSelectedCondition ); - + return true; } @@ -166,7 +166,7 @@ int MODULE_EDITOR_TOOLS::CutCopyFootprint( const TOOL_EVENT& aEvent ) m_copiedModule.reset( new MODULE( *m_frame->GetBoard()->GetFirstModule() ) ); else m_copiedModule.reset( m_frame->LoadFootprint( fpID ) ); - + if( aEvent.IsAction( &PCB_ACTIONS::cutFootprint ) ) DeleteFootprint(aEvent ); @@ -238,12 +238,12 @@ int MODULE_EDITOR_TOOLS::ExportFootprint( const TOOL_EVENT& aEvent ) { LIB_ID fpID = m_frame->GetTreeFPID(); MODULE* fp; - + if( !fpID.IsValid() ) fp = m_frame->GetBoard()->GetFirstModule(); else fp = m_frame->LoadFootprint( fpID ); - + m_frame->Export_Module( fp ); return 0; } diff --git a/pcbnew/tools/pcbnew_picker_tool.h b/pcbnew/tools/pcbnew_picker_tool.h index b30f66a767..a82141278b 100644 --- a/pcbnew/tools/pcbnew_picker_tool.h +++ b/pcbnew/tools/pcbnew_picker_tool.h @@ -73,7 +73,7 @@ public: */ inline void SetClickHandler( CLICK_HANDLER aHandler ) { - assert( !m_clickHandler ); + wxASSERT( !m_clickHandler ); m_clickHandler = aHandler; } @@ -93,7 +93,7 @@ public: */ inline void SetCancelHandler( CANCEL_HANDLER aHandler ) { - assert( !m_cancelHandler ); + wxASSERT( !m_cancelHandler ); m_cancelHandler = aHandler; } @@ -103,7 +103,7 @@ public: */ inline void SetFinalizeHandler( FINALIZE_HANDLER aHandler ) { - assert( !m_finalizeHandler ); + wxASSERT( !m_finalizeHandler ); m_finalizeHandler = aHandler; }