Do not try to read from UI elements that haven't been initialized yet

Fixes https://gitlab.com/kicad/code/kicad/-/issues/13480
This commit is contained in:
Jon Evans 2023-01-12 09:16:11 -05:00
parent d07da51390
commit 595bf70d5d
3 changed files with 11 additions and 1 deletions

View File

@ -1315,6 +1315,10 @@ void PANEL_SETUP_BOARD_STACKUP::ImportSettingsFrom( BOARD* aBoard )
void PANEL_SETUP_BOARD_STACKUP::OnLayersOptionsChanged( LSET aNewLayerSet ) void PANEL_SETUP_BOARD_STACKUP::OnLayersOptionsChanged( LSET aNewLayerSet )
{ {
// Can be called spuriously from events before the layers page is even created
if( !m_panelLayers->IsInitialized() )
return;
// First, verify the list of layers currently in stackup: // First, verify the list of layers currently in stackup:
// if it does not mach the list of layers set in PANEL_SETUP_LAYERS // if it does not mach the list of layers set in PANEL_SETUP_LAYERS
// rebuild the panel // rebuild the panel

View File

@ -128,7 +128,8 @@ PANEL_SETUP_LAYERS::PANEL_SETUP_LAYERS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* a
PANEL_SETUP_LAYERS_BASE( aParent->GetTreebook() ), PANEL_SETUP_LAYERS_BASE( aParent->GetTreebook() ),
m_parentDialog( aParent ), m_parentDialog( aParent ),
m_frame( aFrame ), m_frame( aFrame ),
m_physicalStackup( nullptr ) m_physicalStackup( nullptr ),
m_initialized( false )
{ {
m_pcb = aFrame->GetBoard(); m_pcb = aFrame->GetBoard();
} }
@ -248,6 +249,8 @@ bool PANEL_SETUP_LAYERS::TransferDataToWindow()
setMandatoryLayerCheckBoxes(); setMandatoryLayerCheckBoxes();
setUserDefinedLayerCheckBoxes(); setUserDefinedLayerCheckBoxes();
m_initialized = true;
return true; return true;
} }

View File

@ -91,6 +91,8 @@ public:
m_physicalStackup = aPanel; m_physicalStackup = aPanel;
} }
bool IsInitialized() const { return m_initialized; }
private: private:
void setLayerCheckBox( int layer, bool isChecked ); void setLayerCheckBox( int layer, bool isChecked );
@ -132,6 +134,7 @@ private:
PANEL_SETUP_BOARD_STACKUP* m_physicalStackup; PANEL_SETUP_BOARD_STACKUP* m_physicalStackup;
BOARD* m_pcb; BOARD* m_pcb;
LSET m_enabledLayers; LSET m_enabledLayers;
bool m_initialized;
}; };