diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index f064023098..f70a54d980 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -181,6 +181,9 @@ BOARD::~BOARD() // cause call chains that query the containers for( BOARD_ITEM* item : ownedItems ) delete item; + + // Remove any listeners + RemoveAllListeners(); } diff --git a/pcbnew/widgets/pcb_net_inspector_panel.cpp b/pcbnew/widgets/pcb_net_inspector_panel.cpp index 8807db58fc..4848bb4d2b 100644 --- a/pcbnew/widgets/pcb_net_inspector_panel.cpp +++ b/pcbnew/widgets/pcb_net_inspector_panel.cpp @@ -86,9 +86,6 @@ PCB_NET_INSPECTOR_PANEL::~PCB_NET_INSPECTOR_PANEL() m_netsList->AssociateModel( nullptr ); - if( m_brd != nullptr ) - m_brd->RemoveListener( this ); - // Disconnect from board events m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &PCB_NET_INSPECTOR_PANEL::onUnitsChanged, this ); @@ -865,7 +862,7 @@ void PCB_NET_INSPECTOR_PANEL::OnBoardChanged() { m_brd = m_frame->GetBoard(); - if( m_brd != nullptr ) + if( m_brd ) m_brd->AddListener( this ); m_board_loaded = true;