Move layout updating out of OnUpdateUI to prevent endless looping.

Fixes https://gitlab.com/kicad/code/kicad/issues/4623
This commit is contained in:
Jeff Young 2020-06-05 17:42:20 +01:00
parent 4d6abfdf05
commit 80c0e0080f
1 changed files with 19 additions and 12 deletions

View File

@ -663,6 +663,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
wxCommandEvent cmd_event;
setPadLayersList( m_dummyPad->GetLayerSet() );
OnPadShapeSelection( cmd_event );
OnOffsetCheckbox( cmd_event );
// Update basic shapes list
displayPrimitivesList();
@ -838,6 +839,14 @@ void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
break;
}
// Readjust props book size
wxSize size = m_shapePropsBook->GetSize();
size.y = m_shapePropsBook->GetPage( m_shapePropsBook->GetSelection() )->GetBestSize().y;
m_shapePropsBook->SetMaxSize( size );
for( size_t i = 0; i < m_notebook->GetPageCount(); ++i )
m_notebook->GetPage( i )->Layout();
m_sizeY.Enable( m_PadShape->GetSelection() != CHOICE_SHAPE_CIRCLE
&& m_PadShape->GetSelection() != CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR );
@ -966,22 +975,13 @@ void DIALOG_PAD_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
if( !m_padToDieOpt->IsEnabled() )
m_padToDieOpt->SetValue( false );
// Show/hide extra properties
wxSize size = m_shapePropsBook->GetSize();
size.y = m_shapePropsBook->GetPage( m_shapePropsBook->GetSelection() )->GetBestSize().y;
m_shapePropsBook->SetMaxSize( size );
// Show/hide offset controls
m_offsetCtrls->Show( m_offsetShapeOpt->GetValue() );
m_offsetShapeOptLabel->Show( m_offsetShapeOpt->GetValue() );
// We can show/hide this here because it doesn't require the layout to be refreshed.
// All the others have to be done in their event handlers because doing a layout here
// causes infinite looping on MSW.
m_padToDie.Show( m_padToDieOpt->GetValue() );
// Enable/disable Copper Layers control
m_rbCopperLayersSel->Enable( ii != 4 );
// Adjust for any shown/hidden elements
for( size_t i = 0; i < m_notebook->GetPageCount(); ++i )
m_notebook->GetPage( i )->Layout();
}
@ -1758,6 +1758,13 @@ void DIALOG_PAD_PROPERTIES::OnOffsetCheckbox( wxCommandEvent& event )
m_offsetY.SetValue( m_currentPad->GetOffset().y );
}
// Show/hide controls
m_offsetCtrls->Show( m_offsetShapeOpt->GetValue() );
m_offsetShapeOptLabel->Show( m_offsetShapeOpt->GetValue() );
for( size_t i = 0; i < m_notebook->GetPageCount(); ++i )
m_notebook->GetPage( i )->Layout();
OnValuesChanged( event );
}