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
This commit is contained in:
Jeff Young 2020-12-18 12:21:02 +00:00
parent bf632ad771
commit 01f6c90fac
1 changed files with 18 additions and 19 deletions

View File

@ -907,14 +907,15 @@ DIALOG_NET_INSPECTOR::DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent,
finishDialogSettings(); finishDialogSettings();
#define connect_event( e, f ) \ m_frame->Connect( wxEVT_CLOSE_WINDOW,
m_frame->Connect( e, wxCommandEventHandler( DIALOG_NET_INSPECTOR::f ), nullptr, this ) wxCommandEventHandler( DIALOG_NET_INSPECTOR::onParentWindowClosed ),
nullptr, this );
connect_event( wxEVT_CLOSE_WINDOW, onParentWindowClosed ); m_frame->Connect( UNITS_CHANGED,
connect_event( UNITS_CHANGED, onUnitsChanged ); wxCommandEventHandler( DIALOG_NET_INSPECTOR::onUnitsChanged ),
connect_event( BOARD_CHANGED, onBoardChanged ); nullptr, this );
m_frame->Connect( BOARD_CHANGED,
#undef connect_event wxCommandEventHandler( DIALOG_NET_INSPECTOR::onBoardChanged ),
nullptr, this );
if( m_brd != nullptr ) if( m_brd != nullptr )
{ {
@ -933,14 +934,15 @@ DIALOG_NET_INSPECTOR::~DIALOG_NET_INSPECTOR()
// from now on. so just disassociate it. // from now on. so just disassociate it.
m_netsList->AssociateModel( nullptr ); m_netsList->AssociateModel( nullptr );
#define disconnect_event( e, f ) \ m_frame->Disconnect( wxEVT_CLOSE_WINDOW,
m_frame->Disconnect( e, wxCommandEventHandler( DIALOG_NET_INSPECTOR::f ), nullptr, this ) wxCommandEventHandler( DIALOG_NET_INSPECTOR::onParentWindowClosed ),
nullptr, this );
disconnect_event( wxEVT_CLOSE_WINDOW, onParentWindowClosed ); m_frame->Disconnect( UNITS_CHANGED,
disconnect_event( UNITS_CHANGED, onUnitsChanged ); wxCommandEventHandler( DIALOG_NET_INSPECTOR::onUnitsChanged ),
disconnect_event( BOARD_CHANGED, onBoardChanged ); nullptr, this );
m_frame->Disconnect( BOARD_CHANGED,
#undef disconnect_event wxCommandEventHandler( DIALOG_NET_INSPECTOR::onBoardChanged ),
nullptr, this );
if( m_brd != nullptr ) if( m_brd != nullptr )
m_brd->RemoveListener( this ); m_brd->RemoveListener( this );
@ -991,9 +993,6 @@ void DIALOG_NET_INSPECTOR::onUnitsChanged( wxCommandEvent& event )
void DIALOG_NET_INSPECTOR::onBoardChanged( wxCommandEvent& event ) void DIALOG_NET_INSPECTOR::onBoardChanged( wxCommandEvent& event )
{ {
if( m_brd != nullptr )
m_brd->RemoveListener( this );
m_brd = m_frame->GetBoard(); m_brd = m_frame->GetBoard();
if( m_brd != nullptr ) if( m_brd != nullptr )