diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index c135c07127..6ba4b67805 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -492,6 +492,11 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow() if( field.GetName() == fieldname.m_Name && field.GetText().IsEmpty() ) { m_fields->erase( m_fields->begin() + i ); + + // grid needs to be notified about the size change, + // as it still accesses the data on close (size event) + wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, i, 1 ); + m_grid->ProcessTableMessage( msg ); i--; break; } diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index fc175aca09..4605ba2467 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -275,6 +275,7 @@ wxGridCellAttr* FIELDS_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAtt template wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol ) { + wxCHECK( aRow < GetNumberRows(), wxEmptyString ); const T& field = this->at( (size_t) aRow ); switch( aCol ) @@ -349,6 +350,7 @@ wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol ) template bool FIELDS_GRID_TABLE::GetValueAsBool( int aRow, int aCol ) { + wxCHECK( aRow < GetNumberRows(), false ); const T& field = this->at( (size_t) aRow ); switch( aCol ) @@ -366,6 +368,7 @@ bool FIELDS_GRID_TABLE::GetValueAsBool( int aRow, int aCol ) template void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue ) { + wxCHECK( aRow < GetNumberRows(), /*void*/ ); T& field = this->at( (size_t) aRow ); wxPoint pos; @@ -432,9 +435,11 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue GetView()->Refresh(); } + template void FIELDS_GRID_TABLE::SetValueAsBool( int aRow, int aCol, bool aValue ) { + wxCHECK( aRow < GetNumberRows(), /*void*/ ); T& field = this->at( (size_t) aRow ); switch( aCol ) @@ -503,5 +508,3 @@ void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event ) GRID_TRICKS::doPopupSelection( event ); } } - -