diff options
author | Fawzi Mohamed <fawzi.mohamed@digia.com> | 2013-11-26 16:17:06 +0100 |
---|---|---|
committer | Fawzi Mohamed <fawzi.mohamed@digia.com> | 2013-11-26 16:42:42 +0100 |
commit | 0b80c053e4e02e11043e15eaf59da9e4d02d67bb (patch) | |
tree | b9e262358c35cc8da1f298316d4eafbe6b294e7f /src/plugins/qmljstools/qmljsmodelmanager.cpp | |
parent | ff2d6aa8f755a25a22047cfd83748ab373ea0c1d (diff) | |
download | qt-creator-0b80c053e4e02e11043e15eaf59da9e4d02d67bb.tar.gz |
qmljs: avoid double parsing of imports
Change-Id: Ib45a63e3175924158dc2cff60a7b1964f491c375
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
Diffstat (limited to 'src/plugins/qmljstools/qmljsmodelmanager.cpp')
-rw-r--r-- | src/plugins/qmljstools/qmljsmodelmanager.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index cb6d6f95a2..dff840d5de 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -939,11 +939,15 @@ void ModelManager::importScan(QFutureInterface<void> &future, QVector<ScanItem> pathsToScan; pathsToScan.reserve(paths.size()); - foreach (const QString &path, paths) { - QString cPath = QDir::cleanPath(path); - if (modelManager->m_scannedPaths.contains(cPath)) - continue; - pathsToScan.append(ScanItem(cPath)); + { + QMutexLocker l(&modelManager->m_mutex); + foreach (const QString &path, paths) { + QString cPath = QDir::cleanPath(path); + if (modelManager->m_scannedPaths.contains(cPath)) + continue; + pathsToScan.append(ScanItem(cPath)); + modelManager->m_scannedPaths.insert(cPath); + } } const int maxScanDepth = 5; int progressRange = pathsToScan.size() * (1 << (2 + maxScanDepth)); @@ -989,6 +993,12 @@ void ModelManager::importScan(QFutureInterface<void> &future, future.setProgressValue(progressRange * workDone / totalWork); } future.setProgressValue(progressRange); + if (future.isCanceled()) { + // assume no work has been done + QMutexLocker l(&modelManager->m_mutex); + foreach (const QString &path, paths) + modelManager->m_scannedPaths.remove(path); + } } // Check whether fileMimeType is the same or extends knownMimeType @@ -1104,9 +1114,13 @@ void ModelManager::updateImportPaths() updateSourceFiles(importedFiles, true); QStringList pathToScan; - foreach (QString importPath, allImportPaths) - if (!m_scannedPaths.contains(importPath)) - pathToScan.append(importPath); + { + QMutexLocker l(&m_mutex); + foreach (QString importPath, allImportPaths) + if (!m_scannedPaths.contains(importPath)) { + pathToScan.append(importPath); + } + } if (pathToScan.count() > 1) { QFuture<void> result = QtConcurrent::run(&ModelManager::importScan, |