Don't run onPageChanged() event handler during initialization.

(cherry picked from commit 3f44c811c7)
This commit is contained in:
Jeff Young 2023-05-11 12:37:14 +01:00
parent 3cd87c2a44
commit f35ed59868
1 changed files with 28 additions and 14 deletions

View File

@ -54,10 +54,21 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
_( "Import Settings from Another Board..." ) ),
m_frame( aFrame ),
m_layers( nullptr ),
m_physicalStackup( nullptr )
m_physicalStackup( nullptr ),
m_currentPage( 0 ),
m_layersPage( 0 ),
m_physicalStackupPage( 0 ),
m_boardFinishPage( 0 ),
m_textAndGraphicsPage( 0 ),
m_formattingPage( 0 ),
m_maskAndPagePage( 0 ),
m_constraintsPage( 0 ),
m_tracksAndViasPage( 0 ),
m_netclassesPage( 0 ),
m_severitiesPage( 0 )
{
SetEvtHandlerEnabled( false );
m_currentPage = -1;
/*
* WARNING: If you change page names you MUST update calls to ShowBoardSetupDialog().
@ -198,21 +209,24 @@ void DIALOG_BOARD_SETUP::onPageChanged( wxBookCtrlEvent& aEvent )
size_t page = aEvent.GetSelection();
if( m_currentPage == m_physicalStackupPage || page == m_physicalStackupPage )
if( m_physicalStackupPage > 0 ) // Don't run this during initialization
{
m_layers = RESOLVE_PAGE( PANEL_SETUP_LAYERS, m_layersPage );
m_physicalStackup = RESOLVE_PAGE( PANEL_SETUP_BOARD_STACKUP, m_physicalStackupPage );
if( m_currentPage == m_physicalStackupPage || page == m_physicalStackupPage )
{
m_layers = RESOLVE_PAGE( PANEL_SETUP_LAYERS, m_layersPage );
m_physicalStackup = RESOLVE_PAGE( PANEL_SETUP_BOARD_STACKUP, m_physicalStackupPage );
}
// Ensure layer page always gets updated even if we aren't moving towards it
if( m_currentPage == m_physicalStackupPage )
m_layers->SyncCopperLayers( m_physicalStackup->GetCopperLayerCount() );
if( page == m_physicalStackupPage )
m_physicalStackup->OnLayersOptionsChanged( m_layers->GetUILayerMask() );
else if( Prj().IsReadOnly() )
KIUI::Disable( m_treebook->GetPage( page ) );
}
// Ensure layer page always gets updated even if we aren't moving towards it
if( m_currentPage == m_physicalStackupPage )
m_layers->SyncCopperLayers( m_physicalStackup->GetCopperLayerCount() );
if( page == m_physicalStackupPage )
m_physicalStackup->OnLayersOptionsChanged( m_layers->GetUILayerMask() );
else if( Prj().IsReadOnly() )
KIUI::Disable( m_treebook->GetPage( page ) );
m_currentPage = page;
}