diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index b5013919ab..417eb08c96 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -400,9 +400,7 @@ bool KICAD_MANAGER_FRAME::CloseProject( bool aSave ) mgr.TriggerBackupIfNeeded( NULL_REPORTER::GetInstance() ); if( aSave ) - { mgr.SaveProject(); - } m_active_project = false; mgr.UnloadProject( &Prj() ); diff --git a/kicad/project_tree_pane.cpp b/kicad/project_tree_pane.cpp index c266a95127..bb8f05e561 100644 --- a/kicad/project_tree_pane.cpp +++ b/kicad/project_tree_pane.cpp @@ -32,7 +32,6 @@ #include #include -#include #include #include #include @@ -164,6 +163,12 @@ PROJECT_TREE_PANE::PROJECT_TREE_PANE( KICAD_MANAGER_FRAME* parent ) : PROJECT_TREE_PANE::~PROJECT_TREE_PANE() +{ + shutdownFileWatcher(); +} + + +void PROJECT_TREE_PANE::shutdownFileWatcher() { if( m_watcher ) { @@ -1300,6 +1305,9 @@ void PROJECT_TREE_PANE::FileWatcherReset() void PROJECT_TREE_PANE::EmptyTreePrj() { + // Make sure we don't try to inspect the tree after we've deleted its items. + shutdownFileWatcher(); + m_TreeProject->DeleteAllItems(); } diff --git a/kicad/project_tree_pane.h b/kicad/project_tree_pane.h index 3b1f047f98..519b1aeb5e 100644 --- a/kicad/project_tree_pane.h +++ b/kicad/project_tree_pane.h @@ -155,6 +155,12 @@ private: */ void onIdle( wxIdleEvent &aEvent ); + /** + * Shutdown the file watcher. Used when closing to prevent post-free access into the project + * tree. (Using the destructor doesn't work as wxWidgets defers destruction in some cases.) + */ + void shutdownFileWatcher(); + /** * Function addItemToProjectTree * @brief Add the file or directory aName to the project tree