From 635e8c161490150cdb92420d7ddedc9f3db54561 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 18 Jul 2023 09:09:11 +0200 Subject: [PATCH] Utils: Introduce a FilePathAspect::expandedValue() Currently and long-term synonym for operator(), to be used in cases where (*this)() or such looks ugly. Change-Id: I3f70ecd3298a1df394a0e3cc593917b4c7d36d82 Reviewed-by: Jarek Kobus --- src/libs/utils/aspects.cpp | 9 +++++++-- src/libs/utils/aspects.h | 1 + src/plugins/projectexplorer/buildaspects.cpp | 10 +++++----- .../projectexplorer/runconfigurationaspects.cpp | 4 ++-- src/plugins/qnx/qnxdebugsupport.cpp | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/libs/utils/aspects.cpp b/src/libs/utils/aspects.cpp index 860b6990d8c..55a9ee77fa7 100644 --- a/src/libs/utils/aspects.cpp +++ b/src/libs/utils/aspects.cpp @@ -1325,12 +1325,17 @@ FilePathAspect::FilePathAspect(AspectContainer *container) FilePath FilePathAspect::operator()() const { - return filePath(); + return FilePath::fromUserInput(StringAspect::value()); } FilePath FilePathAspect::value() const { - return filePath(); + return FilePath::fromUserInput(StringAspect::value()); +} + +FilePath FilePathAspect::expandedValue() const +{ + return FilePath::fromUserInput(StringAspect::value()); } QString FilePathAspect::stringValue() const diff --git a/src/libs/utils/aspects.h b/src/libs/utils/aspects.h index a44911202dc..ea12b9b7b82 100644 --- a/src/libs/utils/aspects.h +++ b/src/libs/utils/aspects.h @@ -537,6 +537,7 @@ public: FilePath operator()() const; FilePath value() const; + FilePath expandedValue() const; QString stringValue() const; void setValue(const FilePath &filePath); void setDefaultValue(const FilePath &filePath); diff --git a/src/plugins/projectexplorer/buildaspects.cpp b/src/plugins/projectexplorer/buildaspects.cpp index 683d712b2a1..74650f49c14 100644 --- a/src/plugins/projectexplorer/buildaspects.cpp +++ b/src/plugins/projectexplorer/buildaspects.cpp @@ -74,12 +74,12 @@ void BuildDirectoryAspect::allowInSourceBuilds(const FilePath &sourceDir) { d->sourceDir = sourceDir; makeCheckable(CheckBoxPlacement::Top, Tr::tr("Shadow build:"), QString()); - setChecked(d->sourceDir != filePath()); + setChecked(d->sourceDir != expandedValue()); } bool BuildDirectoryAspect::isShadowBuild() const { - return !d->sourceDir.isEmpty() && d->sourceDir != filePath(); + return !d->sourceDir.isEmpty() && d->sourceDir != expandedValue(); } void BuildDirectoryAspect::setProblem(const QString &description) @@ -92,7 +92,7 @@ void BuildDirectoryAspect::toMap(QVariantMap &map) const { FilePathAspect::toMap(map); if (!d->sourceDir.isEmpty()) { - const FilePath shadowDir = isChecked() ? filePath() : d->savedShadowBuildDir; + const FilePath shadowDir = isChecked() ? expandedValue() : d->savedShadowBuildDir; saveToMap(map, shadowDir.toSettings(), QString(), settingsKey() + ".shadowDir"); } } @@ -104,7 +104,7 @@ void BuildDirectoryAspect::fromMap(const QVariantMap &map) d->savedShadowBuildDir = FilePath::fromSettings(map.value(settingsKey() + ".shadowDir")); if (d->savedShadowBuildDir.isEmpty()) setValue(d->sourceDir); - setChecked(d->sourceDir != filePath()); + setChecked(d->sourceDir != expandedValue()); // FIXME: Check. } } @@ -121,7 +121,7 @@ void BuildDirectoryAspect::addToLayout(Layouting::LayoutItem &parent) setValue(d->savedShadowBuildDir.isEmpty() ? d->sourceDir : d->savedShadowBuildDir); } else { - d->savedShadowBuildDir = filePath(); + d->savedShadowBuildDir = expandedValue(); // FIXME: Check. setValue(d->sourceDir); } }); diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index 3b5d8649b46..4950cef0962 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -632,8 +632,8 @@ void ExecutableAspect::makeOverridable(const QString &overridingKey, const QStri FilePath ExecutableAspect::executable() const { FilePath exe = m_alternativeExecutable && m_alternativeExecutable->isChecked() - ? m_alternativeExecutable->filePath() - : m_executable.filePath(); + ? (*m_alternativeExecutable)() + : m_executable(); if (const IDevice::ConstPtr dev = executionDevice(m_target, m_selector)) exe = dev->rootPath().withNewMappedPath(exe); diff --git a/src/plugins/qnx/qnxdebugsupport.cpp b/src/plugins/qnx/qnxdebugsupport.cpp index 919e9ef1fcc..5ad45f057aa 100644 --- a/src/plugins/qnx/qnxdebugsupport.cpp +++ b/src/plugins/qnx/qnxdebugsupport.cpp @@ -230,7 +230,7 @@ void showAttachToProcessDialog() FilePath localExecutable = dlg.localExecutable(); if (localExecutable.isEmpty()) { if (auto aspect = runConfig->aspect()) - localExecutable = aspect->filePath(); + localExecutable = aspect->expandedValue(); } auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);