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 6c7ace5eba
commit 6cfe5df7c0
2 changed files with 11 additions and 2 deletions
+8 -2
View File
@@ -230,6 +230,12 @@ PROJECT_TREE_PANE::~PROJECT_TREE_PANE()
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();
}
@@ -2709,7 +2715,7 @@ void PROJECT_TREE_PANE::onGitSyncTimer( wxTimerEvent& aEvent )
thread_pool& tp = GetKiCadThreadPool();
tp.push_task(
m_gitSyncTask = tp.submit(
[this]()
{
KIGIT_COMMON* gitCommon = m_TreeProject->GitCommon();
@@ -2743,7 +2749,7 @@ void PROJECT_TREE_PANE::gitStatusTimerHandler()
updateTreeCache();
thread_pool& tp = GetKiCadThreadPool();
tp.push_task(
m_gitStatusIconTask = tp.submit(
[this]()
{
updateGitStatusIconMap();
+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;