diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index c4653df1af..5105fa97af 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -289,7 +289,8 @@ public: { // Commit any pending in-place edits before the row gets moved out from under // the editor. - dynamic_cast( GetView() )->CommitPendingChanges( true ); + if( auto grid = dynamic_cast( GetView() ) ) + grid->CommitPendingChanges( true ); wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, m_rows.size() ); GetView()->ProcessTableMessage( msg ); diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp index 3825ca2b2b..3e28f1a5b5 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp @@ -886,7 +886,10 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnUpdateUI( wxUpdateUIEvent& ) if( grid == m_itemsGrid && row == 0 && col == 0 ) { auto referenceEditor = grid->GetCellEditor( 0, 0 ); - SelectReferenceNumber( dynamic_cast( referenceEditor->GetControl() ) ); + + if( auto textEntry = dynamic_cast( referenceEditor->GetControl() ) ) + SelectReferenceNumber( textEntry ); + referenceEditor->DecRef(); } }