From f7310dd8fbf253e8368429979b27a7bfc51930a6 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 12 Apr 2021 17:14:25 +0200 Subject: [PATCH] ProjectExplorer: Add a RunConfiguration::setRunnableModifier() To override RunConfiguration::runnable() behavior without the need for subclassing. Will be useful for the docker plugin. Change-Id: I9e8511faa95355038b08c3e3be24429d66a5253f Reviewed-by: Alessandro Portale --- src/plugins/projectexplorer/runconfiguration.cpp | 7 +++++++ src/plugins/projectexplorer/runconfiguration.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 7ccb75abbed..542d0732fa3 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -307,6 +307,11 @@ CommandLine RunConfiguration::commandLine() const return m_commandLineGetter(); } +void RunConfiguration::setRunnableModifier(const RunnableModifier &runnableModifier) +{ + m_runnableModifier = runnableModifier; +} + void RunConfiguration::update() { if (m_updater) @@ -398,6 +403,8 @@ Runnable RunConfiguration::runnable() const r.workingDirectory = workingDirectoryAspect->workingDirectory(macroExpander()).toString(); if (auto environmentAspect = aspect()) r.environment = environmentAspect->environment(); + if (m_runnableModifier) + m_runnableModifier(r); return r; } diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 5f3bb71a649..50652f30dd6 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -138,6 +138,9 @@ public: void setCommandLineGetter(const CommandLineGetter &cmdGetter); Utils::CommandLine commandLine() const; + using RunnableModifier = std::function; + void setRunnableModifier(const RunnableModifier &extraModifier); + virtual Runnable runnable() const; // Return a handle to the build system target that created this run configuration. @@ -194,6 +197,7 @@ private: QString m_buildKey; CommandLineGetter m_commandLineGetter; + RunnableModifier m_runnableModifier; Updater m_updater; Utils::MacroExpander m_expander; };