forked from qt-creator/qt-creator
qmljs: avoid double parsing of imports
Change-Id: Ib45a63e3175924158dc2cff60a7b1964f491c375 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -939,11 +939,15 @@ void ModelManager::importScan(QFutureInterface<void> &future,
|
|||||||
|
|
||||||
QVector<ScanItem> pathsToScan;
|
QVector<ScanItem> pathsToScan;
|
||||||
pathsToScan.reserve(paths.size());
|
pathsToScan.reserve(paths.size());
|
||||||
|
{
|
||||||
|
QMutexLocker l(&modelManager->m_mutex);
|
||||||
foreach (const QString &path, paths) {
|
foreach (const QString &path, paths) {
|
||||||
QString cPath = QDir::cleanPath(path);
|
QString cPath = QDir::cleanPath(path);
|
||||||
if (modelManager->m_scannedPaths.contains(cPath))
|
if (modelManager->m_scannedPaths.contains(cPath))
|
||||||
continue;
|
continue;
|
||||||
pathsToScan.append(ScanItem(cPath));
|
pathsToScan.append(ScanItem(cPath));
|
||||||
|
modelManager->m_scannedPaths.insert(cPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const int maxScanDepth = 5;
|
const int maxScanDepth = 5;
|
||||||
int progressRange = pathsToScan.size() * (1 << (2 + maxScanDepth));
|
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 * workDone / totalWork);
|
||||||
}
|
}
|
||||||
future.setProgressValue(progressRange);
|
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
|
// Check whether fileMimeType is the same or extends knownMimeType
|
||||||
@@ -1104,9 +1114,13 @@ void ModelManager::updateImportPaths()
|
|||||||
updateSourceFiles(importedFiles, true);
|
updateSourceFiles(importedFiles, true);
|
||||||
|
|
||||||
QStringList pathToScan;
|
QStringList pathToScan;
|
||||||
|
{
|
||||||
|
QMutexLocker l(&m_mutex);
|
||||||
foreach (QString importPath, allImportPaths)
|
foreach (QString importPath, allImportPaths)
|
||||||
if (!m_scannedPaths.contains(importPath))
|
if (!m_scannedPaths.contains(importPath)) {
|
||||||
pathToScan.append(importPath);
|
pathToScan.append(importPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pathToScan.count() > 1) {
|
if (pathToScan.count() > 1) {
|
||||||
QFuture<void> result = QtConcurrent::run(&ModelManager::importScan,
|
QFuture<void> result = QtConcurrent::run(&ModelManager::importScan,
|
||||||
|
|||||||
Reference in New Issue
Block a user