Browse Source

Remove selection before notifying grid of deletion.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20747

(cherry picked from commit a1cc6403bd)
9.0
Jeff Young 5 months ago
parent
commit
ee62366607
  1. 2
      eeschema/dialogs/dialog_label_properties.cpp
  2. 4
      eeschema/dialogs/dialog_lib_symbol_properties.cpp
  3. 1
      eeschema/dialogs/dialog_sheet_properties.cpp
  4. 4
      eeschema/dialogs/dialog_symbol_properties.cpp
  5. 2
      include/lib_table_grid.h
  6. 2
      pcbnew/dialogs/dialog_footprint_properties.cpp
  7. 3
      pcbnew/dialogs/dialog_footprint_properties_fp_editor.cpp

2
eeschema/dialogs/dialog_label_properties.cpp

@ -797,7 +797,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

4
eeschema/dialogs/dialog_lib_symbol_properties.cpp

@ -633,13 +633,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
@ -714,6 +714,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 )

1
eeschema/dialogs/dialog_sheet_properties.cpp

@ -798,6 +798,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

4
eeschema/dialogs/dialog_symbol_properties.cpp

@ -558,6 +558,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 )
@ -887,13 +889,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

2
include/lib_table_grid.h

@ -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;
}

2
pcbnew/dialogs/dialog_footprint_properties.cpp

@ -724,13 +724,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

3
pcbnew/dialogs/dialog_footprint_properties_fp_editor.cpp

@ -752,7 +752,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 )
@ -762,6 +761,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
@ -813,6 +813,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

Loading…
Cancel
Save