Remove selection before notifying grid of deletion.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20747
This commit is contained in:
Jeff Young 2025-05-29 17:53:36 +01:00
parent 27abe86e0e
commit a1cc6403bd
7 changed files with 13 additions and 5 deletions

View File

@ -818,7 +818,7 @@ void DIALOG_LABEL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
for( int row : selectedRows )
{
//avoids an assert if we deselect early here
m_grid->DeselectRow( row );
m_grid->ClearSelection();
m_fields->erase( m_fields->begin() + row );
// notify the grid

View File

@ -707,13 +707,13 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
}
m_grid->CommitPendingChanges( true /* quiet mode */ );
m_grid->ClearSelection();
// Reverse sort so deleting a row doesn't change the indexes of the other rows.
selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
for( int row : selectedRows )
{
m_grid->ClearSelection();
m_fields->erase( m_fields->begin() + row );
// notify the grid
@ -788,6 +788,8 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnEditSpiceModel( wxCommandEvent& event )
if( !m_grid->CommitPendingChanges() )
return;
m_grid->ClearSelection();
std::vector<SCH_FIELD> fields;
for( const SCH_FIELD& field : *m_fields )

View File

@ -782,6 +782,7 @@ void DIALOG_SHEET_PROPERTIES::OnDeleteField( wxCommandEvent& event )
for( int row : selectedRows )
{
m_grid->ClearSelection();
m_fields->erase( m_fields->begin() + row );
// notify the grid

View File

@ -561,6 +561,8 @@ void DIALOG_SYMBOL_PROPERTIES::OnEditSpiceModel( wxCommandEvent& event )
if( !m_fieldsGrid->CommitPendingChanges() )
return;
m_fieldsGrid->ClearSelection();
std::vector<SCH_FIELD> fields;
for( const SCH_FIELD& field : *m_fields )
@ -901,13 +903,13 @@ void DIALOG_SYMBOL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
}
m_fieldsGrid->CommitPendingChanges( true /* quiet mode */ );
m_fieldsGrid->ClearSelection();
// Reverse sort so deleting a row doesn't change the indexes of the other rows.
selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
for( int row : selectedRows )
{
m_fieldsGrid->ClearSelection();
m_fields->erase( m_fields->begin() + row );
// notify the grid

View File

@ -190,11 +190,13 @@ public:
{
LIB_TABLE_ROWS_ITER start = begin() + aPos;
erase( start, start + aNumRows );
if( GetView() )
{
wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aPos, aNumRows );
GetView()->ProcessTableMessage( msg );
}
return true;
}

View File

@ -729,13 +729,13 @@ void DIALOG_FOOTPRINT_PROPERTIES::OnDeleteField( wxCommandEvent& )
}
m_itemsGrid->CommitPendingChanges( true /* quiet mode */ );
m_itemsGrid->ClearSelection();
// Reverse sort so deleting a row doesn't change the indexes of the other rows.
selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
for( int row : selectedRows )
{
m_itemsGrid->ClearSelection();
m_fields->erase( m_fields->begin() + row );
// notify the grid

View File

@ -799,7 +799,6 @@ void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnDeleteField( wxCommandEvent& event
}
m_itemsGrid->CommitPendingChanges( true /* quiet mode */ );
m_itemsGrid->ClearSelection();
// Reverse sort so deleting a row doesn't change the indexes of the other rows.
selectedRows.Sort( []( int* first, int* second )
@ -809,6 +808,7 @@ void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnDeleteField( wxCommandEvent& event
for( int row : selectedRows )
{
m_itemsGrid->ClearSelection();
m_fields->erase( m_fields->begin() + row );
// notify the grid
@ -860,6 +860,7 @@ void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnDeleteLayer( wxCommandEvent& event
if( curRow < 0 )
return;
m_privateLayersGrid->ClearSelection();
m_privateLayers->erase( m_privateLayers->begin() + curRow );
// notify the grid