Commit 4fbda25b authored by Marco Bubke's avatar Marco Bubke Committed by Thomas Hartmann
Browse files

QmlDesigner: Fix crash for creating a new project in the design mode



There is a hot fix, which is using a timer. This patch is using the
improved approach of testing if a document exists in the new project.

Change-Id: I16ac049c2cc4c0a21ab82fc854c8a062df037f55
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@digia.com>
(cherry picked from commit e263417b

)
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent 0baed045
...@@ -103,7 +103,6 @@ DesignDocument::DesignDocument(QObject *parent) : ...@@ -103,7 +103,6 @@ DesignDocument::DesignDocument(QObject *parent) :
m_documentLoaded(false), m_documentLoaded(false),
m_qtVersionId(-1) m_qtVersionId(-1)
{ {
updateActiveQtVersion();
} }
DesignDocument::~DesignDocument() DesignDocument::~DesignDocument()
...@@ -642,6 +641,8 @@ void DesignDocument::setEditor(Core::IEditor *editor) ...@@ -642,6 +641,8 @@ void DesignDocument::setEditor(Core::IEditor *editor)
connect(editor->document(), connect(editor->document(),
SIGNAL(fileNameChanged(QString,QString)), SIGNAL(fileNameChanged(QString,QString)),
SLOT(updateFileName(QString,QString))); SLOT(updateFileName(QString,QString)));
updateActiveQtVersion();
} }
Core::IEditor *DesignDocument::editor() const Core::IEditor *DesignDocument::editor() const
...@@ -683,7 +684,18 @@ void DesignDocument::redo() ...@@ -683,7 +684,18 @@ void DesignDocument::redo()
viewManager().resetPropertyEditorView(); viewManager().resetPropertyEditorView();
} }
static inline QtSupport::BaseQtVersion *getActiveQtVersion(DesignDocument *controller) static bool isFileInProject(DesignDocument *designDocument, ProjectExplorer::Project *project)
{
foreach (const QString &fileNameInProject, project->files(ProjectExplorer::Project::ExcludeGeneratedFiles)) {
if (designDocument->fileName() == fileNameInProject) {
return true;
}
}
return false;
}
static inline QtSupport::BaseQtVersion *getActiveQtVersion(DesignDocument *designDocument)
{ {
ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance(); ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
ProjectExplorer::Project *currentProject = projectExplorer->currentProject(); ProjectExplorer::Project *currentProject = projectExplorer->currentProject();
...@@ -691,10 +703,13 @@ static inline QtSupport::BaseQtVersion *getActiveQtVersion(DesignDocument *contr ...@@ -691,10 +703,13 @@ static inline QtSupport::BaseQtVersion *getActiveQtVersion(DesignDocument *contr
if (!currentProject) if (!currentProject)
return 0; return 0;
controller->disconnect(controller, SLOT(updateActiveQtVersion())); if (!isFileInProject(designDocument, currentProject))
controller->connect(projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)), controller, SLOT(updateActiveQtVersion())); return 0;
designDocument->disconnect(designDocument, SLOT(updateActiveQtVersion()));
designDocument->connect(projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)), designDocument, SLOT(updateActiveQtVersion()));
controller->connect(currentProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), controller, SLOT(updateActiveQtVersion())); designDocument->connect(currentProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), designDocument, SLOT(updateActiveQtVersion()));
ProjectExplorer::Target *target = currentProject->activeTarget(); ProjectExplorer::Target *target = currentProject->activeTarget();
...@@ -702,7 +717,7 @@ static inline QtSupport::BaseQtVersion *getActiveQtVersion(DesignDocument *contr ...@@ -702,7 +717,7 @@ static inline QtSupport::BaseQtVersion *getActiveQtVersion(DesignDocument *contr
if (!target) if (!target)
return 0; return 0;
controller->connect(target, SIGNAL(kitChanged()), controller, SLOT(updateActiveQtVersion())); designDocument->connect(target, SIGNAL(kitChanged()), designDocument, SLOT(updateActiveQtVersion()));
return QtSupport::QtKitInformation::qtVersion(target->kit()); return QtSupport::QtKitInformation::qtVersion(target->kit());
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment