forked from qt-creator/qt-creator
qmljs: do not rely on future.isCanceled to be sticky
Change-Id: I92f32b9cbea1ddb1660895264f853068c31af4cd Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com> Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -1007,7 +1007,8 @@ void ModelManagerInterface::importScan(QFutureInterface<void> &future,
|
|||||||
future.setProgressRange(0, progressRange); // update max length while iterating?
|
future.setProgressRange(0, progressRange); // update max length while iterating?
|
||||||
const bool libOnly = true; // FIXME remove when tested more
|
const bool libOnly = true; // FIXME remove when tested more
|
||||||
const Snapshot snapshot = modelManager->snapshot();
|
const Snapshot snapshot = modelManager->snapshot();
|
||||||
while (!pathsToScan.isEmpty() && !future.isCanceled()) {
|
bool isCanceled = future.isCanceled();
|
||||||
|
while (!pathsToScan.isEmpty() && !isCanceled) {
|
||||||
ScanItem toScan = pathsToScan.last();
|
ScanItem toScan = pathsToScan.last();
|
||||||
pathsToScan.pop_back();
|
pathsToScan.pop_back();
|
||||||
int pathBudget = (1 << (maxScanDepth + 2 - toScan.depth));
|
int pathBudget = (1 << (maxScanDepth + 2 - toScan.depth));
|
||||||
@@ -1044,9 +1045,10 @@ void ModelManagerInterface::importScan(QFutureInterface<void> &future,
|
|||||||
workDone += pathBudget * 3 / 4;
|
workDone += pathBudget * 3 / 4;
|
||||||
}
|
}
|
||||||
future.setProgressValue(progressRange * workDone / totalWork);
|
future.setProgressValue(progressRange * workDone / totalWork);
|
||||||
|
isCanceled = future.isCanceled();
|
||||||
}
|
}
|
||||||
future.setProgressValue(progressRange);
|
future.setProgressValue(progressRange);
|
||||||
if (future.isCanceled()) {
|
if (isCanceled) {
|
||||||
// assume no work has been done
|
// assume no work has been done
|
||||||
QMutexLocker l(&modelManager->m_mutex);
|
QMutexLocker l(&modelManager->m_mutex);
|
||||||
for (int i = 0; i < paths.size(); ++i)
|
for (int i = 0; i < paths.size(); ++i)
|
||||||
|
|||||||
Reference in New Issue
Block a user