diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.cpp b/pcbnew/board_stackup_manager/panel_board_stackup.cpp index ae9226d957..a816e6f88f 100644 --- a/pcbnew/board_stackup_manager/panel_board_stackup.cpp +++ b/pcbnew/board_stackup_manager/panel_board_stackup.cpp @@ -1315,6 +1315,10 @@ void PANEL_SETUP_BOARD_STACKUP::ImportSettingsFrom( BOARD* aBoard ) 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: // if it does not mach the list of layers set in PANEL_SETUP_LAYERS // rebuild the panel diff --git a/pcbnew/dialogs/panel_setup_layers.cpp b/pcbnew/dialogs/panel_setup_layers.cpp index ad8c302bf7..11248fa51a 100644 --- a/pcbnew/dialogs/panel_setup_layers.cpp +++ b/pcbnew/dialogs/panel_setup_layers.cpp @@ -128,7 +128,8 @@ PANEL_SETUP_LAYERS::PANEL_SETUP_LAYERS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* a PANEL_SETUP_LAYERS_BASE( aParent->GetTreebook() ), m_parentDialog( aParent ), m_frame( aFrame ), - m_physicalStackup( nullptr ) + m_physicalStackup( nullptr ), + m_initialized( false ) { m_pcb = aFrame->GetBoard(); } @@ -248,6 +249,8 @@ bool PANEL_SETUP_LAYERS::TransferDataToWindow() setMandatoryLayerCheckBoxes(); setUserDefinedLayerCheckBoxes(); + m_initialized = true; + return true; } diff --git a/pcbnew/dialogs/panel_setup_layers.h b/pcbnew/dialogs/panel_setup_layers.h index e96aa7b0f4..b60f597d9e 100644 --- a/pcbnew/dialogs/panel_setup_layers.h +++ b/pcbnew/dialogs/panel_setup_layers.h @@ -91,6 +91,8 @@ public: m_physicalStackup = aPanel; } + bool IsInitialized() const { return m_initialized; } + private: void setLayerCheckBox( int layer, bool isChecked ); @@ -132,6 +134,7 @@ private: PANEL_SETUP_BOARD_STACKUP* m_physicalStackup; BOARD* m_pcb; LSET m_enabledLayers; + bool m_initialized; };