diff --git a/common/widgets/color_swatch.cpp b/common/widgets/color_swatch.cpp index 19fa670c14..e462d9a759 100644 --- a/common/widgets/color_swatch.cpp +++ b/common/widgets/color_swatch.cpp @@ -326,7 +326,9 @@ void COLOR_SWATCH::GetNewSwatchColor() void COLOR_SWATCH::OnDarkModeToggle() { - m_checkerboardBg = m_parent->GetBackgroundColour(); + wxWindow* parent = GetParent(); + m_checkerboardBg = parent ? parent->GetBackgroundColour() : wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ); - m_swatch->SetBitmap( makeBitmap() ); + if( m_swatch ) + m_swatch->SetBitmap( makeBitmap() ); } diff --git a/pcb_calculator/calculator_panels/panel_eseries_display.cpp b/pcb_calculator/calculator_panels/panel_eseries_display.cpp index 2d6318d58c..2b555ad999 100644 --- a/pcb_calculator/calculator_panels/panel_eseries_display.cpp +++ b/pcb_calculator/calculator_panels/panel_eseries_display.cpp @@ -70,7 +70,7 @@ PANEL_ESERIES_DISPLAY::PANEL_ESERIES_DISPLAY( wxWindow * parent, wxWindowID id, // making the value boxes appear to be separated from each other. // Also force text to always be black so it is visible against the light // colored cells in both light and dark modes. - wxColour gridLineColour = parent->GetBackgroundColour(); + wxColour gridLineColour = parent ? parent->GetBackgroundColour() : wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ); m_GridEseries112->SetDefaultCellTextColour( *wxBLACK ); m_GridEseries112->SetGridLineColour( gridLineColour );