← Back to team overview

kicad-developers team mailing list archive

PATCH: fix segfault in python scripting caused by new 3D code

 

The attached patch ensures the S3D_MASTER class does not cause
a segfault in pcbnew when used from Python scripting.

The issue is due to an "extern KIWAY* TheKiway" which was exposed
to allow S3D_MASTER to use the new resolver to handle 3D filenames.
Unfortunately TheKiway cannot be assigned a value until a window is
created which implements Kiway. The change introduced by this
patch should not alter the behavior of S3D_MASTER compared to
the behavior before the 3D merge.

The extern variable is only there to support S3D_MASTER which in
turn is there to support the current 3DViewer. In the planned software
structure the rather complex S3D_MASTER class is replaced with
a simple struct which only holds the model name and position/
orientation/scale data as stored in the PCB file; since the replacement
does not perform filename resolution there is no need to expose the
Kiway. For example in Mario's branch we removed the extern and
S3D_MASTER class many months ago.

- Cirilo
=== modified file '3d-viewer/3d_class.cpp'
--- 3d-viewer/3d_class.cpp	2015-12-09 05:43:30 +0000
+++ 3d-viewer/3d_class.cpp	2016-04-05 22:51:29 +0000
@@ -141,8 +141,11 @@
     else
         m_Shape3DFullFilename = m_Shape3DName;
 
-    m_Shape3DFullFilename = TheKiway->Prj().Get3DCacheManager()->GetResolver()
-        ->ResolvePath( m_Shape3DFullFilename );
+    if( NULL != TheKiway )
+    {
+        m_Shape3DFullFilename = TheKiway->Prj().Get3DCacheManager()->GetResolver()
+            ->ResolvePath( m_Shape3DFullFilename );
+    }
 
     return;
 }


Follow ups