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
This commit is contained in:
Seth Hillbrand 2021-09-28 08:41:46 -07:00
parent f73042fe24
commit 42a21e15f0
1 changed files with 5 additions and 3 deletions

View File

@ -374,7 +374,8 @@ void SCH_EDIT_FRAME::setupUIConditions()
auto hasElements = auto hasElements =
[ this ] ( const SELECTION& aSel ) [ 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 ) #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
@ -422,7 +423,8 @@ void SCH_EDIT_FRAME::setupUIConditions()
auto forceHVCond = auto forceHVCond =
[this] ( const SELECTION& ) [this] ( const SELECTION& )
{ {
return eeconfig()->m_Drawing.hv_lines_only; EESCHEMA_SETTINGS* cfg = eeconfig();
return cfg && cfg->m_Drawing.hv_lines_only;
}; };
auto remapSymbolsCondition = auto remapSymbolsCondition =
@ -1557,7 +1559,7 @@ bool SCH_EDIT_FRAME::IsContentModified() const
bool SCH_EDIT_FRAME::GetShowAllPins() const bool SCH_EDIT_FRAME::GetShowAllPins() const
{ {
EESCHEMA_SETTINGS* cfg = eeconfig(); EESCHEMA_SETTINGS* cfg = eeconfig();
return cfg->m_Appearance.show_hidden_pins; return cfg && cfg->m_Appearance.show_hidden_pins;
} }