Move the current selection before deleting the row to avoid asserts
Fixes sentry KICAD-63D
This commit is contained in:
parent
5321c1c481
commit
c816280c6d
|
@ -999,7 +999,6 @@ void DIALOG_LIB_EDIT_PIN_TABLE::AddPin( LIB_PIN* pin )
|
||||||
void DIALOG_LIB_EDIT_PIN_TABLE::OnDeleteRow( wxCommandEvent& event )
|
void DIALOG_LIB_EDIT_PIN_TABLE::OnDeleteRow( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
// TODO: handle delete of multiple rows....
|
// TODO: handle delete of multiple rows....
|
||||||
|
|
||||||
if( !m_grid->CommitPendingChanges() )
|
if( !m_grid->CommitPendingChanges() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1011,16 +1010,17 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnDeleteRow( wxCommandEvent& event )
|
||||||
if( curRow < 0 )
|
if( curRow < 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// move the selection first because wx internally will try to reselect the row we deleted in out of order events
|
||||||
|
int nextSelRow = std::max( curRow-1, 0 );
|
||||||
|
m_grid->GoToCell( nextSelRow, m_grid->GetGridCursorCol() );
|
||||||
|
m_grid->SetGridCursor( nextSelRow, m_grid->GetGridCursorCol() );
|
||||||
|
m_grid->SelectRow( nextSelRow );
|
||||||
|
|
||||||
LIB_PINS removedRow = m_dataModel->RemoveRow( curRow );
|
LIB_PINS removedRow = m_dataModel->RemoveRow( curRow );
|
||||||
|
|
||||||
for( LIB_PIN* pin : removedRow )
|
for( LIB_PIN* pin : removedRow )
|
||||||
m_pins.erase( std::find( m_pins.begin(), m_pins.end(), pin ) );
|
m_pins.erase( std::find( m_pins.begin(), m_pins.end(), pin ) );
|
||||||
|
|
||||||
curRow = std::min( curRow, m_grid->GetNumberRows() - 1 );
|
|
||||||
m_grid->GoToCell( curRow, m_grid->GetGridCursorCol() );
|
|
||||||
m_grid->SetGridCursor( curRow, m_grid->GetGridCursorCol() );
|
|
||||||
m_grid->SelectRow( curRow );
|
|
||||||
|
|
||||||
updateSummary();
|
updateSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue