Commit c4ac5783 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Try to create the puppet only once

Change-Id: I0a56617b262a97e8b5d8007276ebaa09c8cbe4f6
Reviewed-by: default avatarNikita Baryshnikov <nib952051@gmail.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 1065ead5
......@@ -119,6 +119,8 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
PuppetCreator::QmlPuppetVersion puppetVersion = hasQtQuick1(nodeInstanceView) ? PuppetCreator::Qml1Puppet : PuppetCreator::Qml2Puppet;
puppetCreator.createPuppetExecutableIfMissing(puppetVersion);
m_qmlPuppetEditorProcess = puppetCreator.createPuppetProcess(puppetVersion,
"editormode",
socketToken,
......
......@@ -50,6 +50,8 @@
namespace QmlDesigner {
bool PuppetCreator::m_useOnlyFallbackPuppet = !qgetenv("USE_ONLY_FALLBACK_PUPPET").isEmpty();
QHash<Core::Id, PuppetCreator::PuppetType> PuppetCreator::m_qml1PuppetForKitPuppetHash;
QHash<Core::Id, PuppetCreator::PuppetType> PuppetCreator::m_qml2PuppetForKitPuppetHash;
QByteArray PuppetCreator::qtHash() const
{
......@@ -75,21 +77,37 @@ QDateTime PuppetCreator::qtLastModified() const
PuppetCreator::PuppetCreator(ProjectExplorer::Kit *kit, const QString &qtCreatorVersion)
: m_qtCreatorVersion(qtCreatorVersion),
m_kit(kit)
m_kit(kit),
m_availablePuppetType(FallbackPuppet)
{
}
PuppetCreator::~PuppetCreator()
{
m_useOnlyFallbackPuppet = !qgetenv("USE_ONLY_FALLBACK_PUPPET").isEmpty();
}
QProcess *PuppetCreator::createPuppetProcess(PuppetCreator::QmlPuppetVersion puppetVersion, const QString &puppetMode, const QString &socketToken, QObject *handlerObject, const char *outputSlot, const char *finishSlot) const
void PuppetCreator::createPuppetExecutableIfMissing(PuppetCreator::QmlPuppetVersion puppetVersion)
{
if (puppetVersion == Qml1Puppet)
return qmlpuppetProcess(puppetMode, socketToken, handlerObject, outputSlot, finishSlot);
createQml1PuppetExecutableIfMissing();
else
return qml2puppetProcess(puppetMode, socketToken, handlerObject, outputSlot, finishSlot);
createQml2PuppetExecutableIfMissing();
}
QProcess *PuppetCreator::createPuppetProcess(PuppetCreator::QmlPuppetVersion puppetVersion, const QString &puppetMode, const QString &socketToken, QObject *handlerObject, const char *outputSlot, const char *finishSlot) const
{
QString puppetPath;
if (puppetVersion == Qml1Puppet)
puppetPath = qmlpuppetPath(m_availablePuppetType);
else
puppetPath = qml2puppetPath(m_availablePuppetType);
return puppetProcess(puppetPath,
puppetMode,
socketToken,
handlerObject,
outputSlot,
finishSlot);
}
......@@ -115,65 +133,6 @@ QProcess *PuppetCreator::puppetProcess(const QString &puppetPath,
return puppetProcess;
}
QProcess *PuppetCreator::qmlpuppetProcess(const QString &puppetMode,
const QString &socketToken,
QObject *handlerObject,
const char *outputSlot,
const char *finishSlot) const
{
PuppetType puppetType ;
if (!m_useOnlyFallbackPuppet && m_kit) {
if (checkQmlpuppetIsReady()) {
puppetType = UserSpacePuppet;
} else {
bool buildSucceeded = build(qmlpuppetProjectFile());
if (buildSucceeded)
puppetType = UserSpacePuppet;
else
puppetType = FallbackPuppet;
}
} else {
puppetType = FallbackPuppet;
}
return puppetProcess(qmlpuppetPath(puppetType),
puppetMode,
socketToken,
handlerObject,
outputSlot,
finishSlot);
}
QProcess *PuppetCreator::qml2puppetProcess(const QString &puppetMode,
const QString &socketToken,
QObject *handlerObject,
const char *outputSlot,
const char *finishSlot) const
{
PuppetType puppetType ;
if (!m_useOnlyFallbackPuppet && m_kit) {
if (checkQml2puppetIsReady()) {
puppetType = UserSpacePuppet;
} else {
bool buildSucceeded = build(qml2puppetProjectFile());
if (buildSucceeded)
puppetType = UserSpacePuppet;
else
puppetType = FallbackPuppet;
}
} else {
puppetType = FallbackPuppet;
}
return puppetProcess(qml2puppetPath(puppetType),
puppetMode,
socketToken,
handlerObject,
outputSlot,
finishSlot);
}
bool PuppetCreator::build(const QString &qmlPuppetProjectFilePath) const
{
......@@ -206,11 +165,53 @@ bool PuppetCreator::build(const QString &qmlPuppetProjectFilePath) const
}
}
m_useOnlyFallbackPuppet = !buildSucceeded; // fall back to creator puppet and don't compile again
return buildSucceeded;
}
void PuppetCreator::createQml1PuppetExecutableIfMissing()
{
if (!m_useOnlyFallbackPuppet && m_kit) {
if (m_qml1PuppetForKitPuppetHash.contains(m_kit->id())) {
m_availablePuppetType = m_qml1PuppetForKitPuppetHash.value(m_kit->id());
} else if (checkQmlpuppetIsReady()) {
m_availablePuppetType = UserSpacePuppet;
} else {
bool buildSucceeded = build(qmlpuppetProjectFile());
if (buildSucceeded)
m_availablePuppetType = UserSpacePuppet;
else
m_availablePuppetType = FallbackPuppet;
}
m_qml1PuppetForKitPuppetHash.insert(m_kit->id(), m_availablePuppetType);
} else {
m_availablePuppetType = FallbackPuppet;
}
}
void PuppetCreator::createQml2PuppetExecutableIfMissing()
{
if (!m_useOnlyFallbackPuppet && m_kit) {
if (m_qml2PuppetForKitPuppetHash.contains(m_kit->id())) {
m_availablePuppetType = m_qml2PuppetForKitPuppetHash.value(m_kit->id());
} else if (checkQml2puppetIsReady()) {
m_availablePuppetType = UserSpacePuppet;
} else {
bool buildSucceeded = build(qml2puppetProjectFile());
if (buildSucceeded)
m_availablePuppetType = UserSpacePuppet;
else
m_availablePuppetType = FallbackPuppet;
}
m_qml2PuppetForKitPuppetHash.insert(m_kit->id(), m_availablePuppetType);
} else {
m_availablePuppetType = FallbackPuppet;
}
}
QString PuppetCreator::qmlpuppetDirectory(PuppetType puppetType) const
{
......
......@@ -32,6 +32,7 @@
#include <QString>
#include <QProcessEnvironment>
#include <coreplugin/id.h>
namespace ProjectExplorer {
class Kit;
......@@ -57,6 +58,8 @@ public:
PuppetCreator(ProjectExplorer::Kit *kit, const QString &qtCreatorVersion);
~PuppetCreator();
void createPuppetExecutableIfMissing(QmlPuppetVersion puppetVersion);
QProcess *createPuppetProcess(QmlPuppetVersion puppetVersion,
const QString &puppetMode,
const QString &socketToken,
......@@ -69,6 +72,9 @@ public:
protected:
bool build(const QString &qmlPuppetProjectFilePath) const;
void createQml1PuppetExecutableIfMissing();
void createQml2PuppetExecutableIfMissing();
QString qmlpuppetDirectory(PuppetType puppetPathType) const;
QString qmlpuppetFallbackDirectory() const;
QString qml2puppetPath(PuppetType puppetType) const;
......@@ -94,18 +100,6 @@ protected:
const char *outputSlot,
const char *finishSlot) const;
QProcess *qmlpuppetProcess(const QString &puppetMode,
const QString &socketToken,
QObject *handlerObject,
const char *outputSlot,
const char *finishSlot) const;
QProcess *qml2puppetProcess(const QString &puppetMode,
const QString &socketToken,
QObject *handlerObject,
const char *outputSlot,
const char *finishSlot) const;
QProcessEnvironment processEnvironment() const;
QString buildCommand() const;
......@@ -118,8 +112,10 @@ private:
QString m_qtCreatorVersion;
mutable QString m_compileLog;
ProjectExplorer::Kit *m_kit;
PuppetType m_availablePuppetType;
static bool m_useOnlyFallbackPuppet;
static QHash<Core::Id, PuppetType> m_qml1PuppetForKitPuppetHash;
static QHash<Core::Id, PuppetType> m_qml2PuppetForKitPuppetHash;
};
} // namespace QmlDesigner
......
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