From 54589c082877939f1b3425c55878bd9eb2f2f8ab Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 8 Sep 2020 18:19:28 +0200 Subject: [PATCH] FOOTPRINT_WIZARD_FRAME::ParametersUpdated(): fix a reentering issue On wxWidgets 3.0.5, in some cases calling ReCreateParameterList() generates a EVT_GRID_CMD_CELL_CHANGED that call ParametersUpdated() and creating an infinite loop Note also it happens **only for languages using a comma** instead of a point for floating point separator It does not happen on wxWidgets 3.1.4 From master branch --- pcbnew/footprint_wizard_frame_functions.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pcbnew/footprint_wizard_frame_functions.cpp b/pcbnew/footprint_wizard_frame_functions.cpp index 4d0528eff3..451d37f470 100644 --- a/pcbnew/footprint_wizard_frame_functions.cpp +++ b/pcbnew/footprint_wizard_frame_functions.cpp @@ -241,6 +241,9 @@ void FOOTPRINT_WIZARD_FRAME::DefaultParameters( wxCommandEvent& event ) DisplayWizardInfos(); } +// This is a flag to avoid reentering of ParametersUpdated +// that can happen in some cases +static bool lock_update_prms = false; void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) { @@ -252,6 +255,9 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) if( m_parameterGridPage < 0 ) return; + if( lock_update_prms ) + return; + wxArrayString prmValues = footprintWizard->GetParameterValues( m_parameterGridPage ); wxArrayString ptList = footprintWizard->GetParameterTypes( m_parameterGridPage ); @@ -271,7 +277,7 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) if( has_changed ) { - wxString res = footprintWizard->SetParameterValues( m_parameterGridPage, prmValues ); + wxString res = footprintWizard->SetParameterValues( m_parameterGridPage, prmValues ); if( !res.IsEmpty() ) wxMessageBox( res ); @@ -281,8 +287,20 @@ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) // The python script can have modified some other parameters. // So rebuild the current parameter list with new values, just in case. + // + // On wxWidgets 3.0.5, ReCreateParameterList() generates a EVT_GRID_CMD_CELL_CHANGED + // that call ParametersUpdated() and creating an infinite loop + // Note also it happens **only for languages using a comma** instead of a point + // for floating point separator + // It does not happen on wxWidgets 3.1.4 + // + // So lock the next call. + lock_update_prms = true; ReCreateParameterList(); } + + // unlock ParametersUpdated() now the update is finished + lock_update_prms = false; }