Switch update event handlers to use the event instead of pointers

It is safer to use the event to pass the enable/string
instead of pointers, since using the pointers could trigger
other UI events.
This commit is contained in:
Ian McInerney 2021-04-07 17:35:12 +01:00
parent 29cc16a4c4
commit 1a727558b0
3 changed files with 8 additions and 14 deletions

View File

@ -320,8 +320,6 @@ void PANEL_COMMON_SETTINGS::OnPDFViewerClick( wxCommandEvent& event )
void PANEL_COMMON_SETTINGS::onUpdateUIPdfPath( wxUpdateUIEvent& event )
{
bool enabled = m_otherPDFViewer->GetValue();
m_PDFViewerPath->Enable( enabled );
m_pdfViewerBtn->Enable( enabled );
// Used by both the m_pdfViewerBtn and m_PDFViewerPath
event.Enable( m_otherPDFViewer->GetValue() );
}

View File

@ -598,12 +598,7 @@ void SYMBOL_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
void SYMBOL_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event )
{
if( !m_unitSelectBox )
return;
// Using the typical event.Enable() call doesn't seem to work with wxGTK
// so use the pointer to alias combobox to directly enable or disable.
m_unitSelectBox->Enable( m_my_part && m_my_part->GetUnitCount() > 1 );
event.Enable( m_my_part && m_my_part->GetUnitCount() > 1 );
}

View File

@ -272,12 +272,12 @@ void PANEL_SETUP_BOARD_STACKUP::onRemoveDielUI( wxUpdateUIEvent& event )
if( item->GetSublayersCount() > 1 )
{
m_buttonRemoveDielectricLayer->Enable( true );
event.Enable( true );
return;
}
}
m_buttonRemoveDielectricLayer->Enable( false );
event.Enable( false );
}
@ -337,8 +337,9 @@ void PANEL_SETUP_BOARD_STACKUP::onUpdateThicknessValue( wxUpdateUIEvent& event )
wxString thicknessStr = StringFromValue( m_units, thickness, true );
if( m_tcCTValue->GetValue() != thicknessStr )
m_tcCTValue->SetValue( thicknessStr );
// The text in the event will translate to the value for the text control
// and is only updated if it changed
event.SetText( thicknessStr );
}