From b43dade44d60e5c6a631c5d8880afeffcd9094f4 Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed <fawzi.mohamed@nokia.com> Date: Fri, 13 Jan 2012 11:07:20 +0100 Subject: [PATCH] qmljs: fix racing condition with importPaths fixes QTCREATORBUG-6768 Change-Id: I53646df69aa9d0ce97006c68826b02a1452fe4d9 Reviewed-by: Kai Koehne <kai.koehne@nokia.com> --- src/plugins/qmljstools/qmljsmodelmanager.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index 19acd746060..0ac9f0846fe 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -650,6 +650,7 @@ bool ModelManager::matchesMimeType(const Core::MimeType &fileMimeType, const Cor QStringList ModelManager::importPaths() const { + QMutexLocker l(&m_mutex); return m_allImportPaths; } @@ -675,18 +676,24 @@ static QStringList environmentImportPaths() void ModelManager::updateImportPaths() { - m_allImportPaths.clear(); + QStringList allImportPaths; QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projects); while (it.hasNext()) { it.next(); foreach (const QString &path, it.value().importPaths) { const QString canonicalPath = QFileInfo(path).canonicalFilePath(); if (!canonicalPath.isEmpty()) - m_allImportPaths += canonicalPath; + allImportPaths += canonicalPath; } } - m_allImportPaths += m_defaultImportPaths; - m_allImportPaths.removeDuplicates(); + allImportPaths += m_defaultImportPaths; + allImportPaths.removeDuplicates(); + + { + QMutexLocker l(&m_mutex); + m_allImportPaths = allImportPaths; + } + // check if any file in the snapshot imports something new in the new paths Snapshot snapshot = _validSnapshot; -- GitLab