forked from qt-creator/qt-creator
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 <eike.ziller@qt.io>
This commit is contained in:
@@ -391,6 +391,7 @@ void Locator::refresh(QList<ILocatorFilter *> filters)
|
|||||||
|
|
||||||
if (m_refreshTask.isRunning()) {
|
if (m_refreshTask.isRunning()) {
|
||||||
m_refreshTask.cancel();
|
m_refreshTask.cancel();
|
||||||
|
m_refreshTask.waitForFinished();
|
||||||
// this is not ideal because some of the previous filters might have finished, but we
|
// 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
|
// currently cannot find out which part of a map-reduce has finished
|
||||||
filters = Utils::filteredUnique(m_refreshingFilters + filters);
|
filters = Utils::filteredUnique(m_refreshingFilters + filters);
|
||||||
|
|||||||
Reference in New Issue
Block a user