Clear owner of old watcher before resetting std::unique_ptr.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15173
This commit is contained in:
Jeff Young 2023-07-14 19:29:14 +01:00
parent 054252ccbe
commit cbf685ad76
2 changed files with 9 additions and 14 deletions

View File

@ -627,17 +627,18 @@ void SCH_BASE_FRAME::setSymWatcher( const LIB_ID* aID )
{ {
Unbind( wxEVT_FSWATCHER, &SCH_BASE_FRAME::OnSymChange, this ); 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(); m_watcher.reset();
return;
} }
wxString libfullname; wxString libfullname;
SYMBOL_LIB_TABLE* tbl = Prj().SchSymbolLibTable(); SYMBOL_LIB_TABLE* tbl = Prj().SchSymbolLibTable();
if( !tbl ) if( !id || !tbl )
return; return;
try try

View File

@ -1152,18 +1152,12 @@ void PCB_BASE_FRAME::setFPWatcher( FOOTPRINT* aFootprint )
Unbind( wxEVT_FSWATCHER, &PCB_BASE_FRAME::OnFPChange, this ); Unbind( wxEVT_FSWATCHER, &PCB_BASE_FRAME::OnFPChange, this );
if( !aFootprint ) if( m_watcher )
{ {
wxLogTrace( "KICAD_LIB_WATCH", "Remove watch" ); wxLogTrace( "KICAD_LIB_WATCH", "Remove watch" );
m_watcher->RemoveAll();
if( m_watcher ) m_watcher->SetOwner( nullptr );
{ m_watcher.reset();
m_watcher->RemoveAll();
m_watcher->SetOwner( nullptr );
m_watcher.reset();
}
return;
} }
wxString libfullname; wxString libfullname;