From 2e96a5bc9f1a946143613510b29bc1ede07b1d1c Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 5 Aug 2017 16:37:51 +0200 Subject: [PATCH] Pcbnew: fix a crash when editing footprint properties and trying to open the footprint 3D properties. This was due to a missing initialization of the dummy board color settings (used to draw the footprint in the 3D view). Fixes: lp:1708712 https://bugs.launchpad.net/kicad/+bug/1708712 --- 3d-viewer/3d_cache/dialogs/panel_prev_model.cpp | 10 ++++++++++ 3d-viewer/3d_cache/dialogs/panel_prev_model.h | 2 ++ pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp | 1 + pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp | 1 + 4 files changed, 14 insertions(+) diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp b/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp index 9939325c81..2588edee82 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp +++ b/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp @@ -44,11 +44,21 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager, MODULE* aModuleCopy, + COLORS_DESIGN_SETTINGS *aColors, std::vector *aParentInfoList ): PANEL_PREV_3D_BASE( aParent, wxID_ANY ) { initPanel(); + // Initialize the color settings to draw the board and the footprint + if( aColors ) + m_dummyBoard->SetColorsSettings( aColors ); + else + { + static COLORS_DESIGN_SETTINGS defaultColors; + m_dummyBoard->SetColorsSettings( &defaultColors ); + } + if( NULL != aCacheManager ) m_resolver = aCacheManager->GetResolver(); diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_model.h b/3d-viewer/3d_cache/dialogs/panel_prev_model.h index 37fde4d191..bfe8095821 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_model.h +++ b/3d-viewer/3d_cache/dialogs/panel_prev_model.h @@ -68,12 +68,14 @@ class S3D_FILENAME_RESOLVER; class BOARD; class CINFO3D_VISU; class MODULE; +class COLORS_DESIGN_SETTINGS; class PANEL_PREV_3D: public PANEL_PREV_3D_BASE { public: PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager, MODULE* aModuleCopy, + COLORS_DESIGN_SETTINGS *aColors, std::vector *aParentInfoList = NULL ); ~PANEL_PREV_3D(); diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 2a0103b469..ea49892cb2 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -87,6 +87,7 @@ DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR( PCB_EDIT_FRAME* aParent m_PreviewPane = new PANEL_PREV_3D( m_Panel3D, aParent->Prj().Get3DCacheManager(), m_currentModuleCopy, + &aParent->Settings().Colors(), &m_shapes3D_list ); bLowerSizer3D->Add( m_PreviewPane, 1, wxEXPAND, 5 ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index b81e49700d..867337bd85 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -79,6 +79,7 @@ DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR( FOOTPRINT_EDIT_FRAME* m_PreviewPane = new PANEL_PREV_3D( m_Panel3D, aParent->Prj().Get3DCacheManager(), m_currentModuleCopy, + &aParent->Settings().Colors(), &m_shapes3D_list ); bLowerSizer3D->Add( m_PreviewPane, 1, wxEXPAND, 5 );