diff options
author | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2015-08-20 18:02:07 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2015-08-24 12:42:42 +0000 |
commit | 5f3b9dd89c6739024f4f3551d4f9354bd9a3985d (patch) | |
tree | 0344f6ab6f8430c887d9689d410ce37c78bd2a39 /src/plugins/qbsprojectmanager | |
parent | d0655e5cf241a9aa2f4fe0bb5a14e6f022daff8a (diff) | |
download | qt-creator-5f3b9dd89c6739024f4f3551d4f9354bd9a3985d.tar.gz |
QbsProjectManager: Fix working directory handling.
Commit 2dbc5b1032 introduced usage of WorkingDirectoryAspect into the
qbs run configurations for Desktop targets. However, the design of that
class was not suitable for the way our working directory logic works:
There typically is a user-provided value and, as a fallback if the user
does not provide anything, a default value managed by (build system
specific) code. The WorkingDirectoryAspect class could not differentiate
between these two values and so the value stayed forever at the initial
default if the user did not override it, instead of adapting to the
location of the executable.
This patch makes the necessary changes to the WorkingDirectoryAspect
class so that it matches the actual use case.
Task-number: QTCREATORBUG-14891
Change-Id: I7555d0a9cb4b04b75c9215a988278db32eb1ca10
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
Diffstat (limited to 'src/plugins/qbsprojectmanager')
-rw-r--r-- | src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp | 28 | ||||
-rw-r--r-- | src/plugins/qbsprojectmanager/qbsrunconfiguration.h | 2 |
2 files changed, 4 insertions, 26 deletions
diff --git a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp index 8ef4ffbef1..7b5112bdb2 100644 --- a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp +++ b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp @@ -246,21 +246,13 @@ bool QbsRunConfiguration::isConsoleApplication() const QString QbsRunConfiguration::workingDirectory() const { - EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>(); - QTC_ASSERT(aspect, return baseWorkingDirectory()); - return QDir::cleanPath(aspect->environment().expandVariables( - macroExpander()->expand(baseWorkingDirectory()))); + const auto *wdAspect = extraAspect<WorkingDirectoryAspect>(); + QTC_ASSERT(wdAspect, return baseWorkingDirectory()); + return wdAspect->workingDirectory(); } QString QbsRunConfiguration::baseWorkingDirectory() const { - WorkingDirectoryAspect *aspect = extraAspect<WorkingDirectoryAspect>(); - // if the user overrode us, then return his working directory - QString wd = aspect->unexpandedWorkingDirectory(); - if (!wd.isEmpty()) - return wd; - - // else what the pro file reader tells us const QString exe = executable(); if (!exe.isEmpty()) return QFileInfo(executable()).absolutePath(); @@ -272,18 +264,6 @@ QString QbsRunConfiguration::commandLineArguments() const return extraAspect<ArgumentsAspect>()->arguments(); } -void QbsRunConfiguration::setBaseWorkingDirectory(const QString &wd) -{ - WorkingDirectoryAspect *aspect = extraAspect<WorkingDirectoryAspect>(); - const QString &oldWorkingDirectory = workingDirectory(); - - aspect->setWorkingDirectory(wd); - - const QString &newWorkingDirectory = workingDirectory(); - if (oldWorkingDirectory != newWorkingDirectory) - emit baseWorkingDirectoryChanged(newWorkingDirectory); -} - void QbsRunConfiguration::setRunMode(ApplicationLauncher::Mode runMode) { extraAspect<TerminalAspect>()->setRunMode(runMode); @@ -413,7 +393,7 @@ void QbsRunConfigurationWidget::targetInformationHasChanged() setExecutableLineText(m_rc->executable()); WorkingDirectoryAspect *aspect = m_rc->extraAspect<WorkingDirectoryAspect>(); - aspect->pathChooser()->setPath(m_rc->baseWorkingDirectory()); + aspect->setDefaultWorkingDirectory(m_rc->baseWorkingDirectory()); aspect->pathChooser()->setBaseFileName(m_rc->target()->project()->projectDirectory()); m_ignoreChange = false; } diff --git a/src/plugins/qbsprojectmanager/qbsrunconfiguration.h b/src/plugins/qbsprojectmanager/qbsrunconfiguration.h index d6e2be2f23..5d04c9da35 100644 --- a/src/plugins/qbsprojectmanager/qbsrunconfiguration.h +++ b/src/plugins/qbsprojectmanager/qbsrunconfiguration.h @@ -92,7 +92,6 @@ public: bool isConsoleApplication() const; signals: - void baseWorkingDirectoryChanged(const QString&); void targetInformationChanged(); void usingDyldImageSuffixChanged(bool); @@ -104,7 +103,6 @@ private slots: void installStepToBeRemoved(int pos); private: - void setBaseWorkingDirectory(const QString &workingDirectory); QString baseWorkingDirectory() const; QString defaultDisplayName(); qbs::InstallOptions installOptions() const; |