From 7f9d1fb993929ffade441a3f9073f7cbc585d3b9 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 12 Jul 2023 15:33:19 +0200 Subject: [PATCH] QmakeMakeStep: Employ task tree for running Task-number: QTCREATORBUG-29168 Change-Id: I4366c520f58946e372c772c643ac40cdc212ec22 Reviewed-by: hjk --- .../qmakeprojectmanager/qmakemakestep.cpp | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/plugins/qmakeprojectmanager/qmakemakestep.cpp b/src/plugins/qmakeprojectmanager/qmakemakestep.cpp index dccbe73a53c..9d949a09923 100644 --- a/src/plugins/qmakeprojectmanager/qmakemakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakemakestep.cpp @@ -59,15 +59,6 @@ QmakeMakeStep::QmakeMakeStep(BuildStepList *bsl, Id id) setUserArguments("clean"); } supportDisablingForSubdirs(); - - setDoneHook([this](bool success) { - if (!success && !isCanceled() && m_unalignedBuildDir - && settings().warnAgainstUnalignedBuildDir()) { - const QString msg = Tr::tr("The build directory is not at the same level as the source " - "directory, which could be the reason for the build failure."); - emit addTask(BuildSystemTask(Task::Warning, msg)); - } - }); } bool QmakeMakeStep::init() @@ -211,20 +202,31 @@ void QmakeMakeStep::setupOutputFormatter(OutputFormatter *formatter) void QmakeMakeStep::doRun() { - if (m_scriptTarget || m_ignoredNonTopLevelBuild) { - emit finished(true); - return; - } + using namespace Tasking; - if (!m_makeFileToCheck.exists()) { - const bool success = ignoreReturnValue(); - if (!success) - emit addOutput(Tr::tr("Cannot find Makefile. Check your build settings."), BuildStep::OutputFormat::NormalMessage); - emit finished(success); - return; - } + const auto onSetup = [this] { + if (m_scriptTarget || m_ignoredNonTopLevelBuild) + return SetupResult::StopWithDone; - AbstractProcessStep::doRun(); + if (!m_makeFileToCheck.exists()) { + const bool success = ignoreReturnValue(); + if (!success) { + emit addOutput(Tr::tr("Cannot find Makefile. Check your build settings."), + OutputFormat::NormalMessage); + } + return success ? SetupResult::StopWithDone : SetupResult::StopWithError; + } + return SetupResult::Continue; + }; + const auto onError = [this] { + if (m_unalignedBuildDir && settings().warnAgainstUnalignedBuildDir()) { + const QString msg = Tr::tr("The build directory is not at the same level as the source " + "directory, which could be the reason for the build failure."); + emit addTask(BuildSystemTask(Task::Warning, msg)); + } + }; + + runTaskTree({onGroupSetup(onSetup), onGroupError(onError), defaultProcessTask()}); } QStringList QmakeMakeStep::displayArguments() const