diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.h b/src/libs/qmljs/qmljsmodelmanagerinterface.h index ed39a810c3ebda13c9fd9e7d3f37844c2d2ad6d1..b7039dcacf26b5f0f3526faaf605fad5a22e4764 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.h +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.h @@ -33,6 +33,8 @@ #include "qmljs_global.h" #include "qmljsdocument.h" +#include <utils/environment.h> + #include <QObject> #include <QStringList> #include <QSharedPointer> @@ -77,6 +79,7 @@ public: QStringList sourceFiles; QStringList importPaths; QString qmlDumpPath; + Utils::Environment qmlDumpEnvironment; }; class WorkingCopy diff --git a/src/plugins/qmljseditor/qmljsmodelmanager.cpp b/src/plugins/qmljseditor/qmljsmodelmanager.cpp index 27cf5c1ced299d97a8a615a346ce4289a924d616..74adffe02de31b8e12847a999c1a2e902b6209a3 100644 --- a/src/plugins/qmljseditor/qmljsmodelmanager.cpp +++ b/src/plugins/qmljseditor/qmljsmodelmanager.cpp @@ -478,6 +478,7 @@ void ModelManager::onLoadPluginTypes(const QString &libraryPath, const QString & return; QProcess *process = new QProcess(this); + process->setEnvironment(info.qmlDumpEnvironment.toStringList()); connect(process, SIGNAL(finished(int)), SLOT(qmlPluginTypeDumpDone(int))); connect(process, SIGNAL(error(QProcess::ProcessError)), SLOT(qmlPluginTypeDumpError(QProcess::ProcessError))); QStringList args; diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index e74f2683b29906a0843ac1ced9b7fe7b9cdbea03..d928291a7daa4ac5afe8016facfa7ce0732e8b7f 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -131,11 +131,16 @@ void QmlProject::refresh(RefreshOptions options) QmlJS::ModelManagerInterface::ProjectInfo pinfo(this); pinfo.sourceFiles = files(); pinfo.importPaths = importPaths(); + pinfo.qmlDumpPath = Qt4ProjectManager::QmlDumpTool::qmlDumpPath(this); - if (pinfo.qmlDumpPath.isNull()) { - pinfo.qmlDumpPath = Qt4ProjectManager::QmlDumpTool::qmlDumpPath(this); + if (activeTarget()) { + if (const QmlProjectRunConfiguration *runConfig = + qobject_cast<QmlProjectRunConfiguration*>(activeTarget()->activeRunConfiguration())) { + if (runConfig->qtVersion()) { + pinfo.qmlDumpEnvironment = runConfig->qtVersion()->qmlToolsEnvironment(); + } + } } - m_modelManager->updateProjectInfo(pinfo); } diff --git a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp index eb0c7b37d014aee62f2924e811c1d7d34f1f15b1..c84903055ce8579ec01db970482e200483ced86d 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp @@ -34,6 +34,8 @@ #include <coreplugin/modemanager.h> #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/applicationlauncher.h> +#include <projectexplorer/toolchain.h> +#include <qt4projectmanager/qtversionmanager.h> #include <utils/environment.h> #include <utils/qtcassert.h> @@ -62,9 +64,8 @@ namespace Internal { QmlRunControl::QmlRunControl(QmlProjectRunConfiguration *runConfiguration, QString mode) : RunControl(runConfiguration, mode) { - Utils::Environment environment = Utils::Environment::systemEnvironment(); - - m_applicationLauncher.setEnvironment(environment.toStringList()); + if (Qt4ProjectManager::QtVersion *qtVersion = runConfiguration->qtVersion()) + m_applicationLauncher.setEnvironment(qtVersion->qmlToolsEnvironment().toStringList()); m_applicationLauncher.setWorkingDirectory(runConfiguration->workingDirectory()); if (mode == ProjectExplorer::Constants::RUNMODE) { @@ -195,7 +196,6 @@ QWidget *QmlRunControlFactory::createConfigurationWidget(RunConfiguration *runCo ProjectExplorer::RunControl *QmlRunControlFactory::createDebugRunControl(QmlProjectRunConfiguration *runConfig) { - Utils::Environment environment = Utils::Environment::systemEnvironment(); Debugger::DebuggerStartParameters params; params.startMode = Debugger::StartInternal; params.executable = runConfig->observerPath(); @@ -204,7 +204,8 @@ ProjectExplorer::RunControl *QmlRunControlFactory::createDebugRunControl(QmlProj params.processArgs = runConfig->viewerArguments(); params.processArgs.append(QLatin1String("-qmljsdebugger=port:") + QString::number(runConfig->qmlDebugServerPort())); params.workingDirectory = runConfig->workingDirectory(); - params.environment = environment.toStringList(); + if (Qt4ProjectManager::QtVersion *qtVersion = runConfig->qtVersion()) + params.environment = qtVersion->qmlToolsEnvironment().toStringList(); params.displayName = runConfig->displayName(); if (params.executable.isEmpty()) { diff --git a/src/plugins/qt4projectmanager/qmldumptool.cpp b/src/plugins/qt4projectmanager/qmldumptool.cpp index 442598850f91a319180db9a11526db18a8658622..13e6486c410fed7b577d97bb102fd17b3461c386 100644 --- a/src/plugins/qt4projectmanager/qmldumptool.cpp +++ b/src/plugins/qt4projectmanager/qmldumptool.cpp @@ -112,10 +112,9 @@ public slots: foreach (ProjectExplorer::Project *project, m_projectsToUpdate) { QmlJS::ModelManagerInterface::ProjectInfo projectInfo = modelManager->projectInfo(project); - if (projectInfo.qmlDumpPath.isEmpty()) { - projectInfo.qmlDumpPath = qmldumpPath; - modelManager->updateProjectInfo(projectInfo); - } + projectInfo.qmlDumpPath = qmldumpPath; + projectInfo.qmlDumpEnvironment = m_version.qmlToolsEnvironment(); + modelManager->updateProjectInfo(projectInfo); } } diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index af546f26ba1c1c98bde17f14e1970ee0180de9c5..a233fb639fc31066e725f49ad660c7ae64c7a929 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -597,14 +597,12 @@ void Qt4Project::updateQmlJSCodeModel() const QString qtVersionImportPath = qtVersion->versionInfo().value("QT_INSTALL_IMPORTS"); if (!qtVersionImportPath.isEmpty()) projectInfo.importPaths += qtVersionImportPath; + projectInfo.qmlDumpEnvironment = qtVersion->qmlToolsEnvironment(); + projectInfo.qmlDumpPath = QmlDumpTool::qmlDumpPath(this); } } projectInfo.importPaths.removeDuplicates(); - if (projectInfo.qmlDumpPath.isNull()) { - projectInfo.qmlDumpPath = QmlDumpTool::qmlDumpPath(this); - } - modelManager->updateProjectInfo(projectInfo); } diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index 35622017df9d05cd0fab11845cc62de810ff00bb..9b71b4cd0dbc353d94bc5395326f5239a5cf9f20 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -1638,6 +1638,19 @@ bool QtVersion::hasQmlObserver() const return m_hasQmlObserver; } +Utils::Environment QtVersion::qmlToolsEnvironment() const +{ + Utils::Environment environment = Utils::Environment::systemEnvironment(); + addToEnvironment(environment); + + // add preferred toolchain, as that is how the tools are built, compare QtVersion::buildDebuggingHelperLibrary + QList<QSharedPointer<ProjectExplorer::ToolChain> > alltc = toolChains(); + if (!alltc.isEmpty()) + alltc.first().data()->addToEnvironment(environment); + + return environment; +} + QString QtVersion::debuggingHelperLibrary() const { QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index e33e5bd39272f4685caba93c074af137dc4f1940..7f584744c7006e726b0ece5838db4977db8f9640 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -119,6 +119,7 @@ public: bool hasQmlDump() const; bool hasQmlObserver() const; + Utils::Environment qmlToolsEnvironment() const; // Builds a debugging library // returns the output of the commands