forked from qt-creator/qt-creator
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:
@@ -222,6 +222,8 @@ void ModelManager::delayedInitialization()
|
||||
|
||||
connect(ProjectExplorer::SessionManager::instance(), SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
||||
this, SLOT(removeProjectInfo(ProjectExplorer::Project*)));
|
||||
connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
|
||||
SLOT(updateDefaultProjectInfo()));
|
||||
|
||||
QmlJS::ViewerContext qbsVContext;
|
||||
qbsVContext.language = Language::QmlQbs;
|
||||
@@ -257,13 +259,15 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopyInternal() const
|
||||
return workingCopy;
|
||||
}
|
||||
|
||||
ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfo() const
|
||||
void ModelManager::updateDefaultProjectInfo()
|
||||
{
|
||||
// needs to be performed in the ui therad (change?)
|
||||
// needs to be performed in the ui therad
|
||||
ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::currentProject();
|
||||
return defaultProjectInfoForProject(currentProject);
|
||||
ProjectInfo newDefaultProjectInfo = defaultProjectInfoForProject(currentProject);
|
||||
setDefaultProject(projectInfo(currentProject,newDefaultProjectInfo), currentProject);
|
||||
}
|
||||
|
||||
|
||||
// Check whether fileMimeType is the same or extends knownMimeType
|
||||
bool ModelManager::matchesMimeType(const MimeType &fileMimeType, const MimeType &knownMimeType)
|
||||
{
|
||||
|
||||
@@ -70,9 +70,10 @@ public:
|
||||
protected:
|
||||
QHash<QString, QmlJS::Language::Enum> languageForSuffix() const QTC_OVERRIDE;
|
||||
void writeMessageInternal(const QString &msg) const QTC_OVERRIDE;
|
||||
ModelManagerInterface::ProjectInfo defaultProjectInfo() const QTC_OVERRIDE;
|
||||
WorkingCopy workingCopyInternal() const QTC_OVERRIDE;
|
||||
void addTaskInternal(QFuture<void> result, const QString &msg, const char *taskId) const QTC_OVERRIDE;
|
||||
private slots:
|
||||
void updateDefaultProjectInfo();
|
||||
private:
|
||||
void loadDefaultQmlTypeDescriptions();
|
||||
static bool matchesMimeType(const Core::MimeType &fileMimeType, const Core::MimeType &knownMimeType);
|
||||
|
||||
Reference in New Issue
Block a user