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 <alessandro.portale@qt.io>
This commit is contained in:
hjk
2021-04-12 17:14:25 +02:00
parent 454e8a31e2
commit f7310dd8fb
2 changed files with 11 additions and 0 deletions

View File

@@ -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<EnvironmentAspect>())
r.environment = environmentAspect->environment();
if (m_runnableModifier)
m_runnableModifier(r);
return r;
}

View File

@@ -138,6 +138,9 @@ public:
void setCommandLineGetter(const CommandLineGetter &cmdGetter);
Utils::CommandLine commandLine() const;
using RunnableModifier = std::function<void(Runnable &)>;
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;
};