From 9ad5cd5f58a20247e1cc70edee5bc264e6f53405 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 11 Feb 2021 10:27:31 +0100 Subject: [PATCH] Wait for finished the canceled task before starting a new one When Locator::refresh is called, the refresh may be currently ongoing - in this case we cancel it (and don't wait for it to be finished) and start a new refresh. So, in theory, refresh may be running in parallel on more than one non-gui thread. The consequence may be, that when we then shutdown, we wait only for the last refresh to finish (we are connected to m_refreshTask), and doesn't wait for the canceled one to be finished. This may potentially cause a crash. We fix it by ensuring, that only one refresh task is run. Change-Id: I62eeb00375124cdc0ab4651e9280226071d47f3f Reviewed-by: Eike Ziller --- src/plugins/coreplugin/locator/locator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/coreplugin/locator/locator.cpp b/src/plugins/coreplugin/locator/locator.cpp index 2d383d2da99..670f77e2013 100644 --- a/src/plugins/coreplugin/locator/locator.cpp +++ b/src/plugins/coreplugin/locator/locator.cpp @@ -391,6 +391,7 @@ void Locator::refresh(QList filters) if (m_refreshTask.isRunning()) { m_refreshTask.cancel(); + m_refreshTask.waitForFinished(); // this is not ideal because some of the previous filters might have finished, but we // currently cannot find out which part of a map-reduce has finished filters = Utils::filteredUnique(m_refreshingFilters + filters);