← Back to team overview

kicad-developers team mailing list archive

[PATCH] fix crashes related to footprint selection

 

See: https://bugs.launchpad.net/kicad/+bug/1751464

The first one is simple; m_Layers wasn't guaranteed to be null so in my
recent change I introduced a path to crashing when creating a pcb frame.

The second one I am not so sure what is intended, since I haven't really
looked at the code in this area very much, but there was a path to call
LoadEnumeratedFootprint where m_cache is null.  I added a call to
validateCache() to fix this, but I am discarding any exceptions thrown
because I'm not sure how we want to handle them (on my install at least, I
get some exceptions about bad paths, but if I apply this patch, everything
seems to work regardless)

-Jon
From 8acee9dcd85083406ee1919fdb3e1dffb5d696a4 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Sat, 24 Feb 2018 12:16:58 -0500
Subject: [PATCH] Make sure the footprint cache exists in
 LoadEnumeratedFootprint

---
 pcbnew/kicad_plugin.cpp | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp
index e874d5b8a..0106f0857 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() )
@@ -1999,6 +1999,21 @@ MODULE* PCB_IO::LoadEnumeratedFootprint( const wxString& aLibraryPath,
 
     init( aProperties );
 
+    wxString errorMsg;
+
+    try
+    {
+        validateCache( aLibraryPath );
+    }
+    catch( const IO_ERROR& ioe )
+    {
+        errorMsg = ioe.What();
+    }
+
+    // TODO: do we want to do anything with this?
+    // if( !errorMsg.IsEmpty() )
+    //     THROW_IO_ERROR( errorMsg );
+
     const MODULE_MAP& mods = m_cache->GetModules();
 
     MODULE_CITER it = mods.find( aFootprintName );
-- 
2.14.1

From fc11115ea377527b280791a0ba12298339e20df0 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Sat, 24 Feb 2018 11:53:52 -0500
Subject: [PATCH] Ensure m_Layers is null before it is created

---
 pcbnew/pcb_edit_frame.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp
index f4175b8e6..608ec0e85 100644
--- a/pcbnew/pcb_edit_frame.cpp
+++ b/pcbnew/pcb_edit_frame.cpp
@@ -333,6 +333,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
     m_hotkeysDescrList = g_Board_Editor_Hotkeys_Descr;
     m_hasAutoSave = true;
     m_microWaveToolBar = NULL;
+    m_Layers = nullptr;
 
     m_rotationAngle = 900;
 
-- 
2.14.1


Follow ups