Commit f23a5fc4 authored by BogDan Vatra's avatar BogDan Vatra

Set QML[2]_IMPORT_PATH evn variable when running qml[2]puppet

qml[2]puppet can't use any QML plugin that are defined in your .pro file
(using QML_IMPORT_PATH) unless we don't specify it.

Change-Id: I0fffb8a5da1023565fa9fce5cd4cf38f098a0df1
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent 56dab9e9
......@@ -123,32 +123,29 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
m_runModus(runModus),
m_synchronizeId(-1)
{
PuppetCreator puppetCreator(kit, QString());
QString socketToken(QUuid::createUuid().toString());
m_localServer->listen(socketToken);
m_localServer->setMaxPendingConnections(3);
PuppetCreator::QmlPuppetVersion puppetVersion = hasQtQuick1(nodeInstanceView) ? PuppetCreator::Qml1Puppet : PuppetCreator::Qml2Puppet;
PuppetCreator puppetCreator(kit, QString(), nodeInstanceView->model(), puppetVersion);
puppetCreator.createPuppetExecutableIfMissing(puppetVersion);
puppetCreator.createPuppetExecutableIfMissing();
m_qmlPuppetEditorProcess = puppetCreator.createPuppetProcess(puppetVersion,
"editormode",
m_qmlPuppetEditorProcess = puppetCreator.createPuppetProcess("editormode",
socketToken,
this,
SLOT(printEditorProcessOutput()),
SLOT(processFinished(int,QProcess::ExitStatus)));
if (runModus == NormalModus) {
m_qmlPuppetRenderProcess = puppetCreator.createPuppetProcess(puppetVersion,
"rendermode",
m_qmlPuppetRenderProcess = puppetCreator.createPuppetProcess("rendermode",
socketToken,
this,
SLOT(printRenderProcessOutput()),
SLOT(processFinished(int,QProcess::ExitStatus)));
m_qmlPuppetPreviewProcess = puppetCreator.createPuppetProcess(puppetVersion,
"previewmode",
m_qmlPuppetPreviewProcess = puppetCreator.createPuppetProcess("previewmode",
socketToken,
this,
SLOT(printPreviewProcessOutput()),
......
......@@ -114,10 +114,12 @@ bool PuppetCreator::useOnlyFallbackPuppet() const
|| !qgetenv("USE_ONLY_FALLBACK_PUPPET").isEmpty() || m_kit == 0 || !m_kit->isValid();
}
PuppetCreator::PuppetCreator(ProjectExplorer::Kit *kit, const QString &qtCreatorVersion)
PuppetCreator::PuppetCreator(ProjectExplorer::Kit *kit, const QString &qtCreatorVersion, const Model *model, QmlPuppetVersion puppetVersion)
: m_qtCreatorVersion(qtCreatorVersion),
m_kit(kit),
m_availablePuppetType(FallbackPuppet)
m_availablePuppetType(FallbackPuppet),
m_model(model),
m_puppetVersion(puppetVersion)
{
}
......@@ -125,18 +127,18 @@ PuppetCreator::~PuppetCreator()
{
}
void PuppetCreator::createPuppetExecutableIfMissing(PuppetCreator::QmlPuppetVersion puppetVersion)
void PuppetCreator::createPuppetExecutableIfMissing()
{
if (puppetVersion == Qml1Puppet)
if (m_puppetVersion == Qml1Puppet)
createQml1PuppetExecutableIfMissing();
else
createQml2PuppetExecutableIfMissing();
}
QProcess *PuppetCreator::createPuppetProcess(PuppetCreator::QmlPuppetVersion puppetVersion, const QString &puppetMode, const QString &socketToken, QObject *handlerObject, const char *outputSlot, const char *finishSlot) const
QProcess *PuppetCreator::createPuppetProcess(const QString &puppetMode, const QString &socketToken, QObject *handlerObject, const char *outputSlot, const char *finishSlot) const
{
QString puppetPath;
if (puppetVersion == Qml1Puppet)
if (m_puppetVersion == Qml1Puppet)
puppetPath = qmlPuppetPath(m_availablePuppetType);
else
puppetPath = qml2PuppetPath(m_availablePuppetType);
......@@ -332,13 +334,21 @@ QString PuppetCreator::qmlPuppetPath(PuppetType puppetType) const
QProcessEnvironment PuppetCreator::processEnvironment() const
{
#if defined(Q_OS_WIN)
static QLatin1String pathSep(";");
#else
static QLatin1String pathSep(":");
#endif
Utils::Environment environment = Utils::Environment::systemEnvironment();
if (!useOnlyFallbackPuppet())
m_kit->addToEnvironment(environment);
environment.set("QML_BAD_GUI_RENDER_LOOP", "true");
environment.set("QML_USE_MOCKUPS", "true");
environment.set("QML_PUPPET_MODE", "true");
if (m_puppetVersion == Qml1Puppet)
environment.appendOrSet("QML_IMPORT_PATH", m_model->importPaths().join(pathSep), pathSep);
else
environment.appendOrSet("QML2_IMPORT_PATH", m_model->importPaths().join(pathSep), pathSep);
return environment.toProcessEnvironment();
}
......
......@@ -41,6 +41,7 @@ class Kit;
namespace QmlDesigner {
class Model;
class PuppetBuildProgressDialog;
class PuppetCreator
......@@ -56,13 +57,12 @@ public:
Qml2Puppet
};
PuppetCreator(ProjectExplorer::Kit *kit, const QString &qtCreatorVersion);
PuppetCreator(ProjectExplorer::Kit *kit, const QString &qtCreatorVersion, const Model *model, QmlPuppetVersion puppetVersion);
~PuppetCreator();
void createPuppetExecutableIfMissing(QmlPuppetVersion puppetVersion);
void createPuppetExecutableIfMissing();
QProcess *createPuppetProcess(QmlPuppetVersion puppetVersion,
const QString &puppetMode,
QProcess *createPuppetProcess(const QString &puppetMode,
const QString &socketToken,
QObject *handlerObject,
const char *outputSlot,
......@@ -120,6 +120,8 @@ private:
PuppetType m_availablePuppetType;
static QHash<Core::Id, PuppetType> m_qml1PuppetForKitPuppetHash;
static QHash<Core::Id, PuppetType> m_qml2PuppetForKitPuppetHash;
const Model *m_model;
QmlPuppetVersion m_puppetVersion;
};
} // 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