AbstractProcessStep: De-virtualize finish() method

Provide a setDoneHook() setter instead. The hook is
introduced temporarily, as when all the subclasses
are transformed to use the task tree, the done hook
is going to be a part of the subclass' recipe.

Task-number: QTCREATORBUG-29168
Change-Id: Idbc0f8b8a32c8df2fa5ecb73ed1cbaedad99620d
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2023-07-11 20:39:42 +02:00
parent 66ecfb15d1
commit b37b94f0e5
9 changed files with 62 additions and 80 deletions

View File

@@ -82,6 +82,7 @@ public:
std::function<CommandLine()> m_commandLineProvider;
std::function<FilePath()> m_workingDirectoryProvider;
std::function<void(Environment &)> m_environmentModifier;
std::function<void(bool)> m_doneHook; // TODO: Remove me when all subclasses moved to Tasking
bool m_ignoreReturnValue = false;
bool m_lowPriority = false;
std::unique_ptr<QTextDecoder> stdoutStream;
@@ -131,6 +132,11 @@ void AbstractProcessStep::setUseEnglishOutput()
d->m_environmentModifier = [](Environment &env) { env.setupEnglishOutput(); };
}
void AbstractProcessStep::setDoneHook(const std::function<void(bool)> &doneHook)
{
d->m_doneHook = doneHook;
}
void AbstractProcessStep::setCommandLineProvider(const std::function<CommandLine()> &provider)
{
d->m_commandLineProvider = provider;
@@ -350,15 +356,13 @@ void AbstractProcessStep::setDisplayedParameters(ProcessParameters *params)
d->m_displayedParams = params;
}
bool AbstractProcessStep::isSuccess(ProcessResult result) const
{
return result == ProcessResult::FinishedWithSuccess
|| (result == ProcessResult::FinishedWithError && d->m_ignoreReturnValue);
}
void AbstractProcessStep::finish(ProcessResult result)
{
emit finished(isSuccess(result));
const bool success = result == ProcessResult::FinishedWithSuccess
|| (result == ProcessResult::FinishedWithError && d->m_ignoreReturnValue);
if (d->m_doneHook)
d->m_doneHook(success);
emit finished(success);
}
} // namespace ProjectExplorer