From 756d6a123b19a634be7289c960322d8cbd524097 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 1 Sep 2020 09:32:05 +0200 Subject: [PATCH] FOOTPRINT_WIZARD_FRAME: fix a crash when opening the frame. LoadSettings() was using the gal canvas, but the gal canvas was not created when calling LoadSettings(). --- pcbnew/footprint_wizard_frame.cpp | 17 +++++++++-------- pcbnew/pcb_base_frame.cpp | 15 ++++++++++----- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 23976bf84d..dd7369532f 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -4,7 +4,7 @@ * Copyright (C) 2012-2015 Miguel Angel Ajo Pelayo * Copyright (C) 2012-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008-2015 Wayne Stambaugh - * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -105,6 +105,14 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent SetScreen( new PCB_SCREEN( GetPageSizeIU() ) ); GetScreen()->m_Center = true; // Center coordinate origins on screen. + // Create the GAL canvas. + // Must be created before calling LoadSettings() that needs a valid GAL canvas + PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), + m_FrameSize, + GetGalDisplayOptions(), + EDA_DRAW_PANEL_GAL::GAL_FALLBACK ); + SetCanvas( gal_drawPanel ); + LoadSettings( config() ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); @@ -125,13 +133,6 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent GetBoard()->GetDesignSettings().GetDefault()->SetClearance( 0 ); GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false ); - // Create GAL canvas - PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), - m_FrameSize, - GetGalDisplayOptions(), - EDA_DRAW_PANEL_GAL::GAL_FALLBACK ); - SetCanvas( gal_drawPanel ); - PCB_DISPLAY_OPTIONS disp_opts = GetDisplayOptions(); disp_opts.m_DisplayPadIsol = true; diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 03070e1f66..8ed2590060 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -703,13 +703,18 @@ void PCB_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) m_PolarCoords = cfg->m_PolarCoords; } - RENDER_SETTINGS* rs = GetCanvas()->GetView()->GetPainter()->GetSettings(); + wxASSERT( GetCanvas() ); - if( rs ) + if( GetCanvas() ) { - rs->SetHighlightFactor( aCfg->m_Graphics.highlight_factor ); - rs->SetSelectFactor( aCfg->m_Graphics.select_factor ); - rs->SetHighContrastFactor( aCfg->m_Graphics.high_contrast_factor ); + RENDER_SETTINGS* rs = GetCanvas()->GetView()->GetPainter()->GetSettings(); + + if( rs ) + { + rs->SetHighlightFactor( aCfg->m_Graphics.highlight_factor ); + rs->SetSelectFactor( aCfg->m_Graphics.select_factor ); + rs->SetHighContrastFactor( aCfg->m_Graphics.high_contrast_factor ); + } } }