QmlDesigner: Change the priority of projects and kits

First we try to find a project that contains the document.
We fallback to the current project.
If the kit of the active target is invalid we return 0.

Before any newly created qml file used the fallback puppet.

Change-Id: Ide3333455d85418459924e507f4f5e77afae4188
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
Thomas Hartmann
2015-07-09 13:53:12 +02:00
committed by Thomas Hartmann
parent 231404ecac
commit 2f7e85ebcf

View File

@@ -640,16 +640,14 @@ static bool isFileInProject(DesignDocument *designDocument, Project *project)
static inline Kit *getActiveKit(DesignDocument *designDocument) static inline Kit *getActiveKit(DesignDocument *designDocument)
{ {
Project *currentProject = ProjectTree::currentProject(); ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::projectForFile(designDocument->fileName());
if (!currentProject) if (!currentProject)
currentProject = SessionManager::projectForFile(Utils::FileName::fromString(designDocument->fileName())); currentProject = ProjectExplorer::ProjectTree::currentProject();
if (!currentProject) if (!currentProject)
return 0; return 0;
if (!isFileInProject(designDocument, currentProject))
return 0;
QObject::connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged, QObject::connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
designDocument, &DesignDocument::updateActiveQtVersion, Qt::UniqueConnection); designDocument, &DesignDocument::updateActiveQtVersion, Qt::UniqueConnection);
@@ -663,6 +661,8 @@ static inline Kit *getActiveKit(DesignDocument *designDocument)
if (!target) if (!target)
return 0; return 0;
if (!target->kit()->isValid())
return 0;
QObject::connect(target, &Target::kitChanged, QObject::connect(target, &Target::kitChanged,
designDocument, &DesignDocument::updateActiveQtVersion, Qt::UniqueConnection); designDocument, &DesignDocument::updateActiveQtVersion, Qt::UniqueConnection);