From 01f6c90fac25cf2e307e06914c4b4baf3430a470 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 18 Dec 2020 12:21:02 +0000 Subject: [PATCH] BOARD_CHANGED is only called after the previous board has been freed. There is therefore no reason to remove the listener (and every reason not to try). Fixes https://gitlab.com/kicad/code/kicad/issues/6666 --- pcbnew/dialogs/dialog_net_inspector.cpp | 37 ++++++++++++------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/pcbnew/dialogs/dialog_net_inspector.cpp b/pcbnew/dialogs/dialog_net_inspector.cpp index 8b7a3418fd..d45ac567f8 100644 --- a/pcbnew/dialogs/dialog_net_inspector.cpp +++ b/pcbnew/dialogs/dialog_net_inspector.cpp @@ -907,14 +907,15 @@ DIALOG_NET_INSPECTOR::DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent, finishDialogSettings(); -#define connect_event( e, f ) \ - m_frame->Connect( e, wxCommandEventHandler( DIALOG_NET_INSPECTOR::f ), nullptr, this ) - - connect_event( wxEVT_CLOSE_WINDOW, onParentWindowClosed ); - connect_event( UNITS_CHANGED, onUnitsChanged ); - connect_event( BOARD_CHANGED, onBoardChanged ); - -#undef connect_event + m_frame->Connect( wxEVT_CLOSE_WINDOW, + wxCommandEventHandler( DIALOG_NET_INSPECTOR::onParentWindowClosed ), + nullptr, this ); + m_frame->Connect( UNITS_CHANGED, + wxCommandEventHandler( DIALOG_NET_INSPECTOR::onUnitsChanged ), + nullptr, this ); + m_frame->Connect( BOARD_CHANGED, + wxCommandEventHandler( DIALOG_NET_INSPECTOR::onBoardChanged ), + nullptr, this ); if( m_brd != nullptr ) { @@ -933,14 +934,15 @@ DIALOG_NET_INSPECTOR::~DIALOG_NET_INSPECTOR() // from now on. so just disassociate it. m_netsList->AssociateModel( nullptr ); -#define disconnect_event( e, f ) \ - m_frame->Disconnect( e, wxCommandEventHandler( DIALOG_NET_INSPECTOR::f ), nullptr, this ) - - disconnect_event( wxEVT_CLOSE_WINDOW, onParentWindowClosed ); - disconnect_event( UNITS_CHANGED, onUnitsChanged ); - disconnect_event( BOARD_CHANGED, onBoardChanged ); - -#undef disconnect_event + m_frame->Disconnect( wxEVT_CLOSE_WINDOW, + wxCommandEventHandler( DIALOG_NET_INSPECTOR::onParentWindowClosed ), + nullptr, this ); + m_frame->Disconnect( UNITS_CHANGED, + wxCommandEventHandler( DIALOG_NET_INSPECTOR::onUnitsChanged ), + nullptr, this ); + m_frame->Disconnect( BOARD_CHANGED, + wxCommandEventHandler( DIALOG_NET_INSPECTOR::onBoardChanged ), + nullptr, this ); if( m_brd != nullptr ) m_brd->RemoveListener( this ); @@ -991,9 +993,6 @@ void DIALOG_NET_INSPECTOR::onUnitsChanged( wxCommandEvent& event ) void DIALOG_NET_INSPECTOR::onBoardChanged( wxCommandEvent& event ) { - if( m_brd != nullptr ) - m_brd->RemoveListener( this ); - m_brd = m_frame->GetBoard(); if( m_brd != nullptr )