7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 19:59:18 +00:00

Calc mandatoryRows on the fly to prevent initialization order issues.

This commit is contained in:
Jeff Young 2025-01-21 17:00:19 +00:00
parent a0dd0485e9
commit 27755ac317
2 changed files with 15 additions and 8 deletions

View File

@ -50,7 +50,6 @@ wxArrayString g_menuOrientations;
PCB_FIELDS_GRID_TABLE::PCB_FIELDS_GRID_TABLE( PCB_BASE_FRAME* aFrame, DIALOG_SHIM* aDialog ) :
m_frame( aFrame ),
m_dialog( aDialog ),
m_mandatoryRows( 0 ),
m_fieldNameValidator( FIELD_NAME ),
m_referenceValidator( REFERENCE_FIELD ),
m_valueValidator( VALUE_FIELD ),
@ -127,12 +126,6 @@ PCB_FIELDS_GRID_TABLE::PCB_FIELDS_GRID_TABLE( PCB_BASE_FRAME* aFrame, DIALOG_SHI
m_eval = std::make_unique<NUMERIC_EVALUATOR>( m_frame->GetUserUnits() );
for( const PCB_FIELD& field : *this )
{
if( field.IsMandatoryField() )
m_mandatoryRows++;
}
m_frame->Bind( EDA_EVT_UNITS_CHANGED, &PCB_FIELDS_GRID_TABLE::onUnitsChanged, this );
}
@ -151,6 +144,20 @@ PCB_FIELDS_GRID_TABLE::~PCB_FIELDS_GRID_TABLE()
}
int PCB_FIELDS_GRID_TABLE::GetMandatoryRows()
{
int mandatoryRows = 0;
for( const PCB_FIELD& field : *this )
{
if( field.IsMandatoryField() )
mandatoryRows++;
}
return mandatoryRows;
}
void PCB_FIELDS_GRID_TABLE::onUnitsChanged( wxCommandEvent& aEvent )
{
if( GetView() )

View File

@ -62,7 +62,7 @@ public:
int GetNumberRows() override { return (int) size(); }
int GetNumberCols() override { return PFC_COUNT; }
int GetMandatoryRows() { return m_mandatoryRows; }
int GetMandatoryRows();
wxString GetColLabelValue( int aCol ) override;