From 42a21e15f0b46de2112a00366229b13ab5ca09c6 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 28 Sep 2021 08:41:46 -0700 Subject: [PATCH] Check before dereference Fixes a crash where the screen was destroyed during new loading but still gets dereferenced by the UI update. Also puts defensive checks in the UI conditions against null configuration settings --- eeschema/sch_edit_frame.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 15a85e3d27..84dc7e1800 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -374,7 +374,8 @@ void SCH_EDIT_FRAME::setupUIConditions() auto hasElements = [ this ] ( const SELECTION& aSel ) { - return !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ); + return GetScreen() && + ( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) ); }; #define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) @@ -422,7 +423,8 @@ void SCH_EDIT_FRAME::setupUIConditions() auto forceHVCond = [this] ( const SELECTION& ) { - return eeconfig()->m_Drawing.hv_lines_only; + EESCHEMA_SETTINGS* cfg = eeconfig(); + return cfg && cfg->m_Drawing.hv_lines_only; }; auto remapSymbolsCondition = @@ -1557,7 +1559,7 @@ bool SCH_EDIT_FRAME::IsContentModified() const bool SCH_EDIT_FRAME::GetShowAllPins() const { EESCHEMA_SETTINGS* cfg = eeconfig(); - return cfg->m_Appearance.show_hidden_pins; + return cfg && cfg->m_Appearance.show_hidden_pins; }