pcbnew: Check for valid data before deleting
We need to check for valid rows and iterators before removing a 3d model Fixes: lp:1829337 * https://bugs.launchpad.net/kicad/+bug/1829337
This commit is contained in:
parent
97166a72f5
commit
f32c95229e
|
@ -477,7 +477,7 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnRemove3DModel( wxCommandEvent& )
|
|||
|
||||
int idx = m_modelsGrid->GetGridCursorRow();
|
||||
|
||||
if( idx >= 0 )
|
||||
if( idx >= 0 && m_modelsGrid->GetNumberRows() && !m_shapes3D_list.empty() )
|
||||
{
|
||||
m_shapes3D_list.erase( m_shapes3D_list.begin() + idx );
|
||||
m_modelsGrid->DeleteRows( idx, 1 );
|
||||
|
@ -889,6 +889,8 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnUpdateUI( wxUpdateUIEvent& )
|
|||
}
|
||||
m_initialFocus = false;
|
||||
}
|
||||
|
||||
m_buttonRemove->Enable( m_modelsGrid->GetNumberRows() > 0 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -903,4 +905,4 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnGridSize( wxSizeEvent& aEvent )
|
|||
void DIALOG_FOOTPRINT_BOARD_EDITOR::updateOrientationControl()
|
||||
{
|
||||
KIUI::ValidatorTransferToWindowWithoutEvents( m_OrientValidator );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -390,7 +390,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnRemove3DModel( wxCommandEvent& )
|
|||
|
||||
int idx = m_modelsGrid->GetGridCursorRow();
|
||||
|
||||
if( idx >= 0 )
|
||||
if( idx >= 0 && m_modelsGrid->GetNumberRows() && !m_shapes3D_list.empty() )
|
||||
{
|
||||
m_shapes3D_list.erase( m_shapes3D_list.begin() + idx );
|
||||
m_modelsGrid->DeleteRows( idx );
|
||||
|
@ -853,6 +853,8 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnUpdateUI( wxUpdateUIEvent& event )
|
|||
m_delayedFocusRow = -1;
|
||||
m_delayedFocusColumn = -1;
|
||||
}
|
||||
|
||||
m_button3DShapeRemove->Enable( m_modelsGrid->GetNumberRows() > 0 );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue