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
This commit is contained in:
jean-pierre charras 2020-09-08 18:19:28 +02:00
parent 1fdb247167
commit 54589c0828
1 changed files with 19 additions and 1 deletions

View File

@ -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;
}