From f962de966b675c760eefc028700f3afeb43d8d9b Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 24 Feb 2026 10:57:03 -0800 Subject: [PATCH] Fix crash in toolbar conditions during shutdown Guard GetPcbNewSettings() calls in setupUIConditions() lambdas against null return. The settings manager deregisters the PCBNEW_SETTINGS object during cleanup before wxLogGui::Flush finishes, leaving the toolbar idle update to dereference a null pointer. --- pcbnew/pcb_edit_frame.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index da7ce55173..c4d4d25a32 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1105,13 +1105,15 @@ void PCB_EDIT_FRAME::setupUIConditions() auto globalRatsnestCond = [this] (const SELECTION& ) { - return GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest; + PCBNEW_SETTINGS* cfg = GetPcbNewSettings(); + return cfg && cfg->m_Display.m_ShowGlobalRatsnest; }; auto curvedRatsnestCond = [this] (const SELECTION& ) { - return GetPcbNewSettings()->m_Display.m_DisplayRatsnestLinesCurved; + PCBNEW_SETTINGS* cfg = GetPcbNewSettings(); + return cfg && cfg->m_Display.m_DisplayRatsnestLinesCurved; }; auto netHighlightCond = @@ -1146,19 +1148,22 @@ void PCB_EDIT_FRAME::setupUIConditions() const auto isArcKeepCenterMode = [this]( const SELECTION& ) { - return GetPcbNewSettings()->m_ArcEditMode == ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS; + PCBNEW_SETTINGS* cfg = GetPcbNewSettings(); + return cfg && cfg->m_ArcEditMode == ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS; }; const auto isArcKeepEndpointMode = [this]( const SELECTION& ) { - return GetPcbNewSettings()->m_ArcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION; + PCBNEW_SETTINGS* cfg = GetPcbNewSettings(); + return cfg && cfg->m_ArcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION; }; const auto isArcKeepRadiusMode = [this]( const SELECTION& ) { - return GetPcbNewSettings()->m_ArcEditMode == ARC_EDIT_MODE::KEEP_CENTER_ENDS_ADJUST_ANGLE; + PCBNEW_SETTINGS* cfg = GetPcbNewSettings(); + return cfg && cfg->m_ArcEditMode == ARC_EDIT_MODE::KEEP_CENTER_ENDS_ADJUST_ANGLE; }; mgr->SetConditions( ACTIONS::pointEditorArcKeepCenter, CHECK( isArcKeepCenterMode ) );