Bounds checking.

Fixes KICAD-TZK
This commit is contained in:
Jeff Young 2025-08-18 21:22:09 +01:00
parent 91139fe24f
commit 8e45f03bd3

View File

@ -435,31 +435,59 @@ void DIALOG_SHIM::SaveControlState()
if( !key.empty() )
{
if( m_unitBinders.contains( win ) && !m_unitBinders[ win ]->UnitsInvariant() )
if( m_unitBinders.contains( win ) )
{
if( !m_unitBinders[ win ]->UnitsInvariant() )
dlgMap[ key ] = m_unitBinders[ win ]->GetValue();
}
else if( wxComboBox* combo = dynamic_cast<wxComboBox*>( win ) )
{
dlgMap[ key ] = combo->GetValue();
}
else if( wxOwnerDrawnComboBox* od_combo = dynamic_cast<wxOwnerDrawnComboBox*>( win ) )
{
dlgMap[ key ] = od_combo->GetSelection();
}
else if( wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( win ) )
{
dlgMap[ key ] = textEntry->GetValue();
}
else if( wxChoice* choice = dynamic_cast<wxChoice*>( win ) )
{
dlgMap[ key ] = choice->GetSelection();
}
else if( wxCheckBox* check = dynamic_cast<wxCheckBox*>( win ) )
{
dlgMap[ key ] = check->GetValue();
}
else if( wxSpinCtrl* spin = dynamic_cast<wxSpinCtrl*>( win ) )
{
dlgMap[ key ] = spin->GetValue();
}
else if( wxRadioButton* radio = dynamic_cast<wxRadioButton*>( win ) )
{
dlgMap[ key ] = radio->GetValue();
}
else if( wxRadioBox* radioBox = dynamic_cast<wxRadioBox*>( win ) )
{
dlgMap[ key ] = radioBox->GetSelection();
}
else if( wxSplitterWindow* splitter = dynamic_cast<wxSplitterWindow*>( win ) )
{
dlgMap[ key ] = splitter->GetSashPosition();
}
else if( wxScrolledWindow* scrolled = dynamic_cast<wxScrolledWindow*>( win ) )
{
dlgMap[ key ] = scrolled->GetScrollPos( wxVERTICAL );
}
else if( wxNotebook* notebook = dynamic_cast<wxNotebook*>( win ) )
{
int index = notebook->GetSelection();
if( index >= 0 && index < (int) notebook->GetPageCount() )
dlgMap[ key ] = notebook->GetPageText( notebook->GetSelection() );
}
}
for( wxWindow* child : win->GetChildren() )
saveFn( child );