From 2f874097ae99689b5f951d1c046155df613bfac3 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 2 May 2016 16:15:26 +0200 Subject: [PATCH] Fixed a crash in pcbnew (GAL). --- common/draw_panel_gal.cpp | 7 +++---- pcbnew/pcb_draw_panel_gal.cpp | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index a70a94e0e6..e1827198fa 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -52,6 +52,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin wxScrolledCanvas( aParentWindow, aWindowId, aPosition, aSize ) { m_parent = aParentWindow; + m_edaFrame = dynamic_cast( aParentWindow ); m_gal = NULL; m_backend = GAL_TYPE_NONE; m_view = NULL; @@ -105,8 +106,6 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin m_drawingEnabled = false; Connect( wxEVT_TIMER, wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this ); - m_edaFrame = dynamic_cast( aParentWindow ); - LoadGalSettings(); } @@ -373,7 +372,7 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType ) bool EDA_DRAW_PANEL_GAL::SaveGalSettings() { - if( !m_edaFrame ) + if( !m_edaFrame || !m_gal ) return false; wxConfigBase* cfg = Kiface().KifaceSettings(); @@ -391,7 +390,7 @@ bool EDA_DRAW_PANEL_GAL::SaveGalSettings() bool EDA_DRAW_PANEL_GAL::LoadGalSettings() { - if( !m_edaFrame ) + if( !m_edaFrame || !m_gal ) return false; wxConfigBase* cfg = Kiface().KifaceSettings(); diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index 22d6b5de8c..8d55ecc67b 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -109,7 +109,7 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aGalType ) // Load display options (such as filled/outline display of items). // Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class) // which is not always the case (namely when it is used from a wxDialog like the pad editor) - EDA_DRAW_FRAME* frame = dynamic_cast( aParentWindow ); + EDA_DRAW_FRAME* frame = GetParentEDAFrame(); if( frame ) {