Commit cfda627a authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Qmake: Fix workdirectory for qmake projects

The rootProjectNode was not set when the desktopqmakerunconfiguration tried
to use it to figure out the default work directory. Move this code over to
using rootProFile() instead of rootProjectNode(), which is the right thing
to do: rootProFile() is the tree of objects used to parse the qmake project

Task-number: QTCREATORBUG-17728
Change-Id: I76167ba2bbd395d58af7d3bfd50f33c4e37338db
Reviewed-by: default avatarhjk <>
parent f28e6dd0
......@@ -344,8 +344,8 @@ bool DesktopQmakeRunConfiguration::fromMap(const QVariantMap &map)
QString DesktopQmakeRunConfiguration::executable() const
if (QmakeProFileNode *node = projectNode())
return extractWorkingDirAndExecutable(node).second;
if (QmakeProFile *pro = proFile())
return extractWorkingDirAndExecutable(pro).second;
return QString();
......@@ -377,18 +377,18 @@ void DesktopQmakeRunConfiguration::setUsingLibrarySearchPath(bool state)
QString DesktopQmakeRunConfiguration::baseWorkingDirectory() const
if (QmakeProFileNode *node = projectNode())
return extractWorkingDirAndExecutable(node).first;
if (QmakeProFile *pro = proFile())
return extractWorkingDirAndExecutable(pro).first;
return QString();
bool DesktopQmakeRunConfiguration::isConsoleApplication() const
if (QmakeProFileNode *node = projectNode()) {
const QStringList config = node->variableValue(Variable::Config);
if (QmakeProFile *pro = proFile()) {
const QStringList config = pro->variableValue(Variable::Config);
if (!config.contains("console") || config.contains("testcase"))
return false;
const QStringList qt = node->variableValue(Variable::Qt);
const QStringList qt = pro->variableValue(Variable::Qt);
return !qt.contains("testlib") && !qt.contains("qmltest");
return false;
......@@ -402,11 +402,11 @@ void DesktopQmakeRunConfiguration::addToBaseEnvironment(Environment &env) const
// The user could be linking to a library found via a -L/some/dir switch
// to find those libraries while actually running we explicitly prepend those
// dirs to the library search path
const QmakeProFileNode *node = projectNode();
if (m_isUsingLibrarySearchPath && node) {
const QStringList libDirectories = node->variableValue(Variable::LibDirectories);
const QmakeProFile *pro = proFile();
if (m_isUsingLibrarySearchPath && pro) {
const QStringList libDirectories = pro->variableValue(Variable::LibDirectories);
if (!libDirectories.isEmpty()) {
const QString proDirectory = node->buildDir();
const QString proDirectory = pro->buildDir().toString();
foreach (QString dir, libDirectories) {
// Fix up relative entries like "LIBS+=-L.."
const QFileInfo fi(dir);
......@@ -415,7 +415,7 @@ void DesktopQmakeRunConfiguration::addToBaseEnvironment(Environment &env) const
} // foreach
} // libDirectories
} // node
} // pro
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(target()->kit());
if (qtVersion && m_isUsingLibrarySearchPath)
......@@ -437,20 +437,18 @@ QmakeProject *DesktopQmakeRunConfiguration::qmakeProject() const
return static_cast<QmakeProject *>(target()->project());
QmakeProFileNode *DesktopQmakeRunConfiguration::projectNode() const
QmakeProFile *DesktopQmakeRunConfiguration::proFile() const
QmakeProject *project = qmakeProject();
QTC_ASSERT(project, return nullptr);
QmakeProFileNode *rootNode = project->rootProjectNode();
if (!rootNode)
return nullptr;
return rootNode->findProFileFor(m_proFilePath);
QmakeProFile *rootProFile = project->rootProFile();
return rootProFile ? rootProFile->findProFile(m_proFilePath) : nullptr;
QString DesktopQmakeRunConfiguration::defaultDisplayName()
if (QmakeProFileNode *node = projectNode())
return node->displayName();
if (QmakeProFile *pro = proFile())
return pro->displayName();
QString defaultName;
if (!m_proFilePath.isEmpty())
......@@ -465,19 +463,16 @@ OutputFormatter *DesktopQmakeRunConfiguration::createOutputFormatter() const
return new QtSupport::QtOutputFormatter(target()->project());
QPair<QString, QString> DesktopQmakeRunConfiguration::extractWorkingDirAndExecutable(const QmakeProFileNode *node) const
QPair<QString, QString> DesktopQmakeRunConfiguration::extractWorkingDirAndExecutable(const QmakeProFile *proFile) const
if (!node)
return { };
if (!proFile)
return {};
QmakeProFile *pro = node->proFile();
QTC_ASSERT(pro, return { });
TargetInformation ti = pro->targetInformation();
TargetInformation ti = proFile->targetInformation();
if (!ti.valid)
return qMakePair(QString(), QString());
const QStringList &config = pro->variableValue(Variable::Config);
const QStringList &config = proFile->variableValue(Variable::Config);
QString destDir = ti.destDir.toString();
QString workingDir;
......@@ -98,12 +98,12 @@ protected:
bool fromMap(const QVariantMap &map) override;
QPair<QString, QString> extractWorkingDirAndExecutable(const QmakeProFileNode *node) const;
QPair<QString, QString> extractWorkingDirAndExecutable(const QmakeProFile *proFile) const;
QString baseWorkingDirectory() const;
QString defaultDisplayName();
bool isConsoleApplication() const;
QmakeProject *qmakeProject() const;
QmakeProFileNode *projectNode() const;
QmakeProFile *proFile() const;
void ctor();
Subproject commit 0f62e829be66816831e1f04247dfb850912c3d50
Subproject commit 24000d556fefdb3dcd4103d3d1679429434e6f58
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