Fix crash when CallAfter is called while destructing thread pool on exit.

PROJECT_TREE_PANE is already destructed at that point.
This commit is contained in:
Alex Shvartzkop
2026-01-13 00:56:54 +05:00
parent a3a12399f2
commit 8b348d20d9
2 changed files with 11 additions and 2 deletions
+8 -2
View File
@@ -269,6 +269,12 @@ PROJECT_TREE_PANE::~PROJECT_TREE_PANE()
Unbind( wxEVT_TIMER, wxTimerEventHandler( PROJECT_TREE_PANE::onGitSyncTimer ), this, m_gitSyncTimer.GetId() );
Unbind( wxEVT_TIMER, wxTimerEventHandler( PROJECT_TREE_PANE::onGitStatusTimer ), this, m_gitStatusTimer.GetId() );
shutdownFileWatcher();
if( m_gitSyncTask.valid() )
m_gitSyncTask.wait();
if( m_gitStatusIconTask.valid() )
m_gitStatusIconTask.wait();
}
@@ -2404,7 +2410,7 @@ void PROJECT_TREE_PANE::onGitSyncTimer( wxTimerEvent& aEvent )
thread_pool& tp = GetKiCadThreadPool();
tp.detach_task( [this]()
m_gitSyncTask = tp.submit_task( [this]()
{
KIGIT_COMMON* gitCommon = m_TreeProject->GitCommon();
@@ -2449,7 +2455,7 @@ void PROJECT_TREE_PANE::gitStatusTimerHandler()
updateTreeCache();
thread_pool& tp = GetKiCadThreadPool();
tp.detach_task( [this]() { updateGitStatusIconMap(); } );
m_gitStatusIconTask = tp.submit_task( [this]() { updateGitStatusIconMap(); } );
}
void PROJECT_TREE_PANE::onGitStatusTimer( wxTimerEvent& aEvent )
+3
View File
@@ -34,6 +34,7 @@
#include <mutex>
#include <unordered_map>
#include <vector>
#include <future>
#include <wx/datetime.h>
#include <wx/fswatcher.h>
#include <wx/laywin.h>
@@ -322,6 +323,8 @@ private:
wxString m_gitCurrentBranchName;
wxTimer m_gitSyncTimer;
wxTimer m_gitStatusTimer;
std::future<void> m_gitSyncTask;
std::future<void> m_gitStatusIconTask;
std::mutex m_gitTreeCacheMutex;
std::unordered_map<wxString, wxTreeItemId> m_gitTreeCache;