qmljs: fix race condition in defaultVContext

defaultVContext did call defaultProjectInfo which could
be called only from the ui thread (as it did check the current
project)
Now update the defaultProjectInfo via signals, and lock on access
making defaultProjectInfo threadsafe.

Task-number: QTCREATORBUG-12556
Change-Id: Ibffeb59bbcef7120f08766160bb1e2ddc9af2922
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
Fawzi Mohamed
2014-06-30 11:56:28 +02:00
parent b013637f22
commit 329952f5ee
4 changed files with 41 additions and 14 deletions

View File

@@ -171,7 +171,8 @@ public:
QrcResourceSelector resources = AllQrcResources);
QList<ProjectInfo> projectInfos() const;
ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
ProjectInfo projectInfo(ProjectExplorer::Project *project,
const ModelManagerInterface::ProjectInfo &defaultValue = ProjectInfo()) const;
void updateProjectInfo(const ProjectInfo &pinfo, ProjectExplorer::Project *p);
void updateDocument(QmlJS::Document::Ptr doc);
@@ -218,6 +219,7 @@ protected slots:
void asyncReset();
virtual void startCppQmlTypeUpdate();
protected:
QMutex *mutex() const;
virtual QHash<QString,Language::Enum> languageForSuffix() const;
virtual void writeMessageInternal(const QString &msg) const;
virtual WorkingCopy workingCopyInternal() const;
@@ -250,6 +252,7 @@ protected:
void maybeScan(const QStringList &importPaths, Language::Enum defaultLanguage);
void updateImportPaths();
void loadQmlTypeDescriptionsInternal(const QString &path);
void setDefaultProject(const ProjectInfo &pInfo, ProjectExplorer::Project *p);
private:
mutable QMutex m_mutex;
@@ -274,6 +277,8 @@ private:
// project integration
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;
ProjectInfo m_defaultProjectInfo;
ProjectExplorer::Project *m_defaultProject;
QMultiHash<QString, ProjectExplorer::Project *> m_fileToProject;
PluginDumper *m_pluginDumper;