From 81ee5edcafcf949e692ad0953ea95a6a35a41c50 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Mon, 13 Jan 2020 15:22:26 +0000 Subject: [PATCH] Test dynamic_cast for safety from future changes --- eeschema/dialogs/dialog_lib_edit_pin_table.cpp | 3 ++- pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) 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(); } }