From cfda627abc9f89f195d412d2e9e28679295b11cf Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 4 Apr 2017 14:49:51 +0200 Subject: [PATCH] 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 now. Task-number: QTCREATORBUG-17728 Change-Id: I76167ba2bbd395d58af7d3bfd50f33c4e37338db Reviewed-by: hjk --- .../desktopqmakerunconfiguration.cpp | 49 +++++++++---------- .../desktopqmakerunconfiguration.h | 4 +- src/shared/qbs | 2 +- 3 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp index 88c6b3f78a2..2c9ea0dd02c 100644 --- a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp @@ -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 env.prependOrSetLibrarySearchPath(dir); } // 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(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 DesktopQmakeRunConfiguration::extractWorkingDirAndExecutable(const QmakeProFileNode *node) const +QPair 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; diff --git a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h index d32cd008a52..18ece5ecd4e 100644 --- a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h +++ b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h @@ -98,12 +98,12 @@ protected: bool fromMap(const QVariantMap &map) override; private: - QPair extractWorkingDirAndExecutable(const QmakeProFileNode *node) const; + QPair extractWorkingDirAndExecutable(const QmakeProFile *proFile) const; QString baseWorkingDirectory() const; QString defaultDisplayName(); bool isConsoleApplication() const; QmakeProject *qmakeProject() const; - QmakeProFileNode *projectNode() const; + QmakeProFile *proFile() const; void ctor(); diff --git a/src/shared/qbs b/src/shared/qbs index 0f62e829be6..24000d556fe 160000 --- a/src/shared/qbs +++ b/src/shared/qbs @@ -1 +1 @@ -Subproject commit 0f62e829be66816831e1f04247dfb850912c3d50 +Subproject commit 24000d556fefdb3dcd4103d3d1679429434e6f58