Shut down fileWatcher more aggresively.

While I haven't been able to reproduce the crash, my theory is that
those that do are running into situations where wxWidgets defers
destructing the window.

Fixes https://gitlab.com/kicad/code/kicad/issues/8458
This commit is contained in:
Jeff Young 2021-05-20 16:52:49 +01:00
parent 78a475d75b
commit e8102d85dc
3 changed files with 15 additions and 3 deletions

View File

@ -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() );

View File

@ -32,7 +32,6 @@
#include <wx/textdlg.h>
#include <bitmaps.h>
#include <common.h>
#include <gestfich.h>
#include <macros.h>
#include <menus_helpers.h>
@ -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();
}

View File

@ -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