From e4ae894c96c476dc6874a81f492380e00fa0fbdb Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 6 Oct 2023 13:23:53 +0200 Subject: [PATCH] FileApiReader: Make stopping faster On the session switch we are busy waiting for the running async task, started before by the FileApiReader::endState(). This blocks the main thread for considerable amount of time. E.g. when switching between sessions both containing Qt project, it may block the main thread up to 10 seconds. Instead, we employ the future synchronizer and move the awaiting to the shutdown phase. The next patch is going to limit the awaiting in shutdown phase. Task-number: QTCREATORBUG-27729 Change-Id: I956ed26edcd699d8a4e2b9309d109963f1d4bb20 Reviewed-by: Cristian Adam --- src/plugins/cmakeprojectmanager/fileapireader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/fileapireader.cpp b/src/plugins/cmakeprojectmanager/fileapireader.cpp index 7c27c2e5b53..a3038815b4e 100644 --- a/src/plugins/cmakeprojectmanager/fileapireader.cpp +++ b/src/plugins/cmakeprojectmanager/fileapireader.cpp @@ -11,10 +11,13 @@ #include +#include + #include #include #include +#include #include #include @@ -168,7 +171,7 @@ void FileApiReader::stop() if (m_future) { m_future->cancel(); - m_future->waitForFinished(); + ExtensionSystem::PluginManager::futureSynchronizer()->addFuture(*m_future); } m_future = {}; m_isParsing = false;