From cbf685ad7695e631700afb12d008729541159fc6 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 14 Jul 2023 19:29:14 +0100 Subject: [PATCH] Clear owner of old watcher before resetting std::unique_ptr. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15173 --- eeschema/sch_base_frame.cpp | 9 +++++---- pcbnew/pcb_base_frame.cpp | 14 ++++---------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 774834d164..f3c92d3414 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -627,17 +627,18 @@ void SCH_BASE_FRAME::setSymWatcher( const LIB_ID* aID ) { Unbind( wxEVT_FSWATCHER, &SCH_BASE_FRAME::OnSymChange, this ); - if( !aID ) + if( m_watcher ) { - wxLogTrace( "KICAD_LIB_WATCH", "No symbol library specified, disabling watcher" ); + wxLogTrace( "KICAD_LIB_WATCH", "Remove watch" ); + m_watcher->RemoveAll(); + m_watcher->SetOwner( nullptr ); m_watcher.reset(); - return; } wxString libfullname; SYMBOL_LIB_TABLE* tbl = Prj().SchSymbolLibTable(); - if( !tbl ) + if( !id || !tbl ) return; try diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 12390edb80..82645f975a 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -1152,18 +1152,12 @@ void PCB_BASE_FRAME::setFPWatcher( FOOTPRINT* aFootprint ) Unbind( wxEVT_FSWATCHER, &PCB_BASE_FRAME::OnFPChange, this ); - if( !aFootprint ) + if( m_watcher ) { wxLogTrace( "KICAD_LIB_WATCH", "Remove watch" ); - - if( m_watcher ) - { - m_watcher->RemoveAll(); - m_watcher->SetOwner( nullptr ); - m_watcher.reset(); - } - - return; + m_watcher->RemoveAll(); + m_watcher->SetOwner( nullptr ); + m_watcher.reset(); } wxString libfullname;