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

Set complete build environment (MinGW).

Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>

Task-number: QTCREATORBUG-2883
(cherry picked from commit f1fb0bddb1)
This commit is contained in:
Friedemann Kleint
2010-10-26 15:39:37 +02:00
committed by dt
parent efb173390a
commit 791bb483fd
8 changed files with 37 additions and 16 deletions

View File

@@ -33,6 +33,8 @@
#include "qmljs_global.h" #include "qmljs_global.h"
#include "qmljsdocument.h" #include "qmljsdocument.h"
#include <utils/environment.h>
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
#include <QSharedPointer> #include <QSharedPointer>
@@ -77,6 +79,7 @@ public:
QStringList sourceFiles; QStringList sourceFiles;
QStringList importPaths; QStringList importPaths;
QString qmlDumpPath; QString qmlDumpPath;
Utils::Environment qmlDumpEnvironment;
}; };
class WorkingCopy class WorkingCopy

View File

@@ -478,6 +478,7 @@ void ModelManager::onLoadPluginTypes(const QString &libraryPath, const QString &
return; return;
QProcess *process = new QProcess(this); QProcess *process = new QProcess(this);
process->setEnvironment(info.qmlDumpEnvironment.toStringList());
connect(process, SIGNAL(finished(int)), SLOT(qmlPluginTypeDumpDone(int))); connect(process, SIGNAL(finished(int)), SLOT(qmlPluginTypeDumpDone(int)));
connect(process, SIGNAL(error(QProcess::ProcessError)), SLOT(qmlPluginTypeDumpError(QProcess::ProcessError))); connect(process, SIGNAL(error(QProcess::ProcessError)), SLOT(qmlPluginTypeDumpError(QProcess::ProcessError)));
QStringList args; QStringList args;

View File

@@ -131,11 +131,16 @@ void QmlProject::refresh(RefreshOptions options)
QmlJS::ModelManagerInterface::ProjectInfo pinfo(this); QmlJS::ModelManagerInterface::ProjectInfo pinfo(this);
pinfo.sourceFiles = files(); pinfo.sourceFiles = files();
pinfo.importPaths = importPaths(); pinfo.importPaths = importPaths();
pinfo.qmlDumpPath = Qt4ProjectManager::QmlDumpTool::qmlDumpPath(this);
if (pinfo.qmlDumpPath.isNull()) { if (activeTarget()) {
pinfo.qmlDumpPath = Qt4ProjectManager::QmlDumpTool::qmlDumpPath(this); if (const QmlProjectRunConfiguration *runConfig =
qobject_cast<QmlProjectRunConfiguration*>(activeTarget()->activeRunConfiguration())) {
if (runConfig->qtVersion()) {
pinfo.qmlDumpEnvironment = runConfig->qtVersion()->qmlToolsEnvironment();
}
}
} }
m_modelManager->updateProjectInfo(pinfo); m_modelManager->updateProjectInfo(pinfo);
} }

View File

@@ -34,6 +34,8 @@
#include <coreplugin/modemanager.h> #include <coreplugin/modemanager.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/applicationlauncher.h> #include <projectexplorer/applicationlauncher.h>
#include <projectexplorer/toolchain.h>
#include <qt4projectmanager/qtversionmanager.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -62,9 +64,8 @@ namespace Internal {
QmlRunControl::QmlRunControl(QmlProjectRunConfiguration *runConfiguration, QString mode) QmlRunControl::QmlRunControl(QmlProjectRunConfiguration *runConfiguration, QString mode)
: RunControl(runConfiguration, mode) : RunControl(runConfiguration, mode)
{ {
Utils::Environment environment = Utils::Environment::systemEnvironment(); if (Qt4ProjectManager::QtVersion *qtVersion = runConfiguration->qtVersion())
m_applicationLauncher.setEnvironment(qtVersion->qmlToolsEnvironment().toStringList());
m_applicationLauncher.setEnvironment(environment.toStringList());
m_applicationLauncher.setWorkingDirectory(runConfiguration->workingDirectory()); m_applicationLauncher.setWorkingDirectory(runConfiguration->workingDirectory());
if (mode == ProjectExplorer::Constants::RUNMODE) { if (mode == ProjectExplorer::Constants::RUNMODE) {
@@ -195,7 +196,6 @@ QWidget *QmlRunControlFactory::createConfigurationWidget(RunConfiguration *runCo
ProjectExplorer::RunControl *QmlRunControlFactory::createDebugRunControl(QmlProjectRunConfiguration *runConfig) ProjectExplorer::RunControl *QmlRunControlFactory::createDebugRunControl(QmlProjectRunConfiguration *runConfig)
{ {
Utils::Environment environment = Utils::Environment::systemEnvironment();
Debugger::DebuggerStartParameters params; Debugger::DebuggerStartParameters params;
params.startMode = Debugger::StartInternal; params.startMode = Debugger::StartInternal;
params.executable = runConfig->observerPath(); params.executable = runConfig->observerPath();
@@ -204,7 +204,8 @@ ProjectExplorer::RunControl *QmlRunControlFactory::createDebugRunControl(QmlProj
params.processArgs = runConfig->viewerArguments(); params.processArgs = runConfig->viewerArguments();
params.processArgs.append(QLatin1String("-qmljsdebugger=port:") + QString::number(runConfig->qmlDebugServerPort())); params.processArgs.append(QLatin1String("-qmljsdebugger=port:") + QString::number(runConfig->qmlDebugServerPort()));
params.workingDirectory = runConfig->workingDirectory(); params.workingDirectory = runConfig->workingDirectory();
params.environment = environment.toStringList(); if (Qt4ProjectManager::QtVersion *qtVersion = runConfig->qtVersion())
params.environment = qtVersion->qmlToolsEnvironment().toStringList();
params.displayName = runConfig->displayName(); params.displayName = runConfig->displayName();
if (params.executable.isEmpty()) { if (params.executable.isEmpty()) {

View File

@@ -112,10 +112,9 @@ public slots:
foreach (ProjectExplorer::Project *project, m_projectsToUpdate) { foreach (ProjectExplorer::Project *project, m_projectsToUpdate) {
QmlJS::ModelManagerInterface::ProjectInfo projectInfo = modelManager->projectInfo(project); QmlJS::ModelManagerInterface::ProjectInfo projectInfo = modelManager->projectInfo(project);
if (projectInfo.qmlDumpPath.isEmpty()) { projectInfo.qmlDumpPath = qmldumpPath;
projectInfo.qmlDumpPath = qmldumpPath; projectInfo.qmlDumpEnvironment = m_version.qmlToolsEnvironment();
modelManager->updateProjectInfo(projectInfo); modelManager->updateProjectInfo(projectInfo);
}
} }
} }

View File

@@ -597,14 +597,12 @@ void Qt4Project::updateQmlJSCodeModel()
const QString qtVersionImportPath = qtVersion->versionInfo().value("QT_INSTALL_IMPORTS"); const QString qtVersionImportPath = qtVersion->versionInfo().value("QT_INSTALL_IMPORTS");
if (!qtVersionImportPath.isEmpty()) if (!qtVersionImportPath.isEmpty())
projectInfo.importPaths += qtVersionImportPath; projectInfo.importPaths += qtVersionImportPath;
projectInfo.qmlDumpEnvironment = qtVersion->qmlToolsEnvironment();
projectInfo.qmlDumpPath = QmlDumpTool::qmlDumpPath(this);
} }
} }
projectInfo.importPaths.removeDuplicates(); projectInfo.importPaths.removeDuplicates();
if (projectInfo.qmlDumpPath.isNull()) {
projectInfo.qmlDumpPath = QmlDumpTool::qmlDumpPath(this);
}
modelManager->updateProjectInfo(projectInfo); modelManager->updateProjectInfo(projectInfo);
} }

View File

@@ -1638,6 +1638,19 @@ bool QtVersion::hasQmlObserver() const
return m_hasQmlObserver; 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 QtVersion::debuggingHelperLibrary() const
{ {
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");

View File

@@ -119,6 +119,7 @@ public:
bool hasQmlDump() const; bool hasQmlDump() const;
bool hasQmlObserver() const; bool hasQmlObserver() const;
Utils::Environment qmlToolsEnvironment() const;
// Builds a debugging library // Builds a debugging library
// returns the output of the commands // returns the output of the commands