qmljs: fix racing condition with importPaths

fixes QTCREATORBUG-6768

Change-Id: I53646df69aa9d0ce97006c68826b02a1452fe4d9
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Fawzi Mohamed
2012-01-13 11:07:20 +01:00
parent c287d90604
commit b43dade44d

View File

@@ -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;