Commit f1fb0bdd authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Debugger/JS Code model: Set environment for QML tools correctly.



Set complete build environment (MinGW).
Reviewed-by: default avatarChristian Kamm <christian.d.kamm@nokia.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>

Task-number: QTCREATORBUG-2883
parent 5cb791d7
......@@ -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
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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()) {
......
......@@ -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);
}
}
......
......@@ -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);
}
......
......@@ -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");
......
......@@ -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
......
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