diff --git a/src/libs/solutions/tasking/tasktree.h b/src/libs/solutions/tasking/tasktree.h index 946922dda3f..cd918e78f30 100644 --- a/src/libs/solutions/tasking/tasktree.h +++ b/src/libs/solutions/tasking/tasktree.h @@ -368,8 +368,8 @@ private: constexpr bool isVoid = std::is_same_v, Task &>>; static_assert(isDynamic || isVoid, - "Task setup handler needs to take (Task &) as an argument (optionally) and has to " - "return void or SetupResult. The passed handler doesn't fulfill these requirements."); + "Task setup handler needs to take (Task &) as an argument and has to return " + "void or SetupResult. The passed handler doesn't fulfill these requirements."); return [=](TaskInterface &taskInterface) { Adapter &adapter = static_cast(taskInterface); if constexpr (isDynamic) @@ -383,37 +383,45 @@ private: static GroupItem::TaskDoneHandler wrapDone(Handler &&handler) { if constexpr (std::is_same_v) return {}; // When user passed {} for the done handler. - static constexpr bool is2ArgDynamic + static constexpr bool isBTD // stands for [B]ool, [T]ask, [D]oneWith = std::is_invocable_r_v, const Task &, DoneWith>; - static constexpr bool is1ArgDynamic + static constexpr bool isBT = std::is_invocable_r_v, const Task &>; - static constexpr bool is0ArgDynamic + static constexpr bool isBD + = std::is_invocable_r_v, DoneWith>; + static constexpr bool isB = std::is_invocable_r_v>; - static constexpr bool is2ArgVoid + static constexpr bool isVTD // stands for [V]oid, [T]ask, [D]oneWith = std::is_invocable_r_v, const Task &, DoneWith>; - static constexpr bool is1ArgVoid + static constexpr bool isVT = std::is_invocable_r_v, const Task &>; - static constexpr bool is0ArgVoid + static constexpr bool isVD + = std::is_invocable_r_v, DoneWith>; + static constexpr bool isV = std::is_invocable_r_v>; - static constexpr bool isInvocable = is2ArgDynamic || is2ArgVoid - || is1ArgDynamic || is1ArgVoid - || is0ArgDynamic || is0ArgVoid; + static constexpr bool isInvocable = isBTD || isBT || isBD || isB + || isVTD || isVT || isVD || isV; static_assert(isInvocable, - "Task done handler needs to take (const Task &, bool) as arguments (optionally) and " - "has to return void or bool. The passed handler doesn't fulfill these requirements."); + "Task done handler needs to take (const Task &, DoneWith), (const Task &), " + "(DoneWith) or (void) as arguments and has to return void or bool. " + "The passed handler doesn't fulfill these requirements."); return [=](const TaskInterface &taskInterface, DoneWith result) { const Adapter &adapter = static_cast(taskInterface); - if constexpr (is2ArgDynamic) + if constexpr (isBTD) return std::invoke(handler, *adapter.task(), result); - if constexpr (is1ArgDynamic) + if constexpr (isBT) return std::invoke(handler, *adapter.task()); - if constexpr (is0ArgDynamic) + if constexpr (isBD) + return std::invoke(handler, result); + if constexpr (isB) return std::invoke(handler); - if constexpr (is2ArgVoid) + if constexpr (isVTD) std::invoke(handler, *adapter.task(), result); - else if constexpr (is1ArgVoid) + else if constexpr (isVT) std::invoke(handler, *adapter.task()); - else if constexpr (is0ArgVoid) + else if constexpr (isVD) + std::invoke(handler, result); + else if constexpr (isV) std::invoke(handler); return result == DoneWith::Success; }; diff --git a/src/plugins/android/androidsdkdownloader.cpp b/src/plugins/android/androidsdkdownloader.cpp index 492417d2353..947b6042adf 100644 --- a/src/plugins/android/androidsdkdownloader.cpp +++ b/src/plugins/android/androidsdkdownloader.cpp @@ -171,7 +171,7 @@ void AndroidSdkDownloader::downloadAndExtractSdk() unarchiver.setDestDir(sdkFileName.parentDir()); return SetupResult::Continue; }; - const auto onUnarchiverDone = [this, storage](const Unarchiver &, DoneWith result) { + const auto onUnarchiverDone = [this, storage](DoneWith result) { if (result != DoneWith::Success) { logError(Tr::tr("Unarchiving error.")); return; diff --git a/src/plugins/debugger/loadcoredialog.cpp b/src/plugins/debugger/loadcoredialog.cpp index 88722a4e259..143bada6ae5 100644 --- a/src/plugins/debugger/loadcoredialog.cpp +++ b/src/plugins/debugger/loadcoredialog.cpp @@ -253,12 +253,12 @@ void AttachCoreDialog::accepted() AsyncTask{[this, copyFileAsync](auto &task) { task.setConcurrentCallData(copyFileAsync, coreFile()); }, - [=](const auto &task) { d->coreFileResult = task.result(); }, + [=](const Async &task) { d->coreFileResult = task.result(); }, CallDoneIf::Success}, AsyncTask{[this, copyFileAsync](auto &task) { task.setConcurrentCallData(copyFileAsync, symbolFile()); }, - [=](const auto &task) { d->symbolFileResult = task.result(); }, + [=](const Async &task) { d->symbolFileResult = task.result(); }, CallDoneIf::Success} }; diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp index ceab92cb7f6..2210f15ca8b 100644 --- a/src/plugins/diffeditor/diffeditorplugin.cpp +++ b/src/plugins/diffeditor/diffeditorplugin.cpp @@ -110,7 +110,7 @@ DiffFilesController::DiffFilesController(IDocument *document) const TreeStorage>> storage; - const auto setupTree = [this, storage](TaskTree &taskTree) { + const auto onTreeSetup = [this, storage](TaskTree &taskTree) { QList> *outputList = storage.activeStorage(); const QList inputList = reloadInputList(); @@ -147,7 +147,7 @@ DiffFilesController::DiffFilesController(IDocument *document) const Group root = { Storage(storage), - TaskTreeTask(setupTree), + TaskTreeTask(onTreeSetup), onGroupDone(onTreeDone), onGroupError(onTreeError) }; diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 24b02b736b7..9b0d3dad168 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -483,7 +483,7 @@ ShowController::ShowController(IDocument *document, const QString &id) updateDescription(*data); }; - const auto setupFollows = [this, storage, updateDescription](TaskTree &taskTree) { + const auto onFollowsSetup = [this, storage, updateDescription](TaskTree &taskTree) { ReloadStorage *data = storage.activeStorage(); QStringList parents; QString errorMessage; @@ -536,7 +536,7 @@ ShowController::ShowController(IDocument *document, const QString &id) onGroupSetup(desciptionDetailsSetup), ProcessTask(onBranchesSetup, onBranchesDone, CallDoneIf::Success), ProcessTask(onPrecedesSetup, onPrecedesDone, CallDoneIf::Success), - TaskTreeTask(setupFollows) + TaskTreeTask(onFollowsSetup) } }, Group { diff --git a/src/plugins/projectexplorer/copystep.cpp b/src/plugins/projectexplorer/copystep.cpp index 412dc2dfc55..be6c9bb730f 100644 --- a/src/plugins/projectexplorer/copystep.cpp +++ b/src/plugins/projectexplorer/copystep.cpp @@ -52,7 +52,7 @@ private: streamer.setDestination(m_target); return SetupResult::Continue; }; - const auto onDone = [this](const FileStreamer &, DoneWith result) { + const auto onDone = [this](DoneWith result) { if (result == DoneWith::Success) addOutput(Tr::tr("Copying finished."), OutputFormat::NormalMessage); else diff --git a/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp b/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp index 141e2cd5e60..e0fa0f15764 100644 --- a/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp +++ b/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp @@ -198,11 +198,11 @@ GroupItem QnxDeployQtLibrariesDialogPrivate::uploadTask() GroupItem QnxDeployQtLibrariesDialogPrivate::chmodTask(const DeployableFile &file) { - const auto onSetup = [=](Process &process) { + const auto onSetup = [this, file](Process &process) { process.setCommand({m_device->filePath("chmod"), {"a+x", Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath())}}); }; - const auto onError = [=](const Process &process) { + const auto onError = [this, file](const Process &process) { const QString error = process.errorString(); if (!error.isEmpty()) { emitWarningMessage(Tr::tr("Remote chmod failed for file \"%1\": %2") @@ -217,7 +217,7 @@ GroupItem QnxDeployQtLibrariesDialogPrivate::chmodTask(const DeployableFile &fil GroupItem QnxDeployQtLibrariesDialogPrivate::chmodTree() { - const auto setupChmodHandler = [=](TaskTree &tree) { + const auto onSetup = [this](TaskTree &tree) { QList filesToChmod; for (const DeployableFile &file : std::as_const(m_deployableFiles)) { if (file.isExecutable()) @@ -230,7 +230,7 @@ GroupItem QnxDeployQtLibrariesDialogPrivate::chmodTree() } tree.setRecipe(chmodList); }; - return TaskTreeTask{setupChmodHandler}; + return TaskTreeTask(onSetup); } Group QnxDeployQtLibrariesDialogPrivate::deployRecipe() diff --git a/src/plugins/qnx/slog2inforunner.cpp b/src/plugins/qnx/slog2inforunner.cpp index c6c2bff84a8..aa7d8b9aa80 100644 --- a/src/plugins/qnx/slog2inforunner.cpp +++ b/src/plugins/qnx/slog2inforunner.cpp @@ -37,7 +37,7 @@ void Slog2InfoRunner::start() const auto onTestSetup = [this](Process &process) { process.setCommand({device()->filePath("slog2info"), {}}); }; - const auto onTestDone = [this](const Process &, DoneWith result) { + const auto onTestDone = [this](DoneWith result) { if (result == DoneWith::Success) { m_found = true; return; diff --git a/src/plugins/remotelinux/genericdirectuploadstep.cpp b/src/plugins/remotelinux/genericdirectuploadstep.cpp index 9f3de9bc21b..a1d11de47ab 100644 --- a/src/plugins/remotelinux/genericdirectuploadstep.cpp +++ b/src/plugins/remotelinux/genericdirectuploadstep.cpp @@ -151,7 +151,7 @@ GroupItem GenericDirectUploadStep::statTask(UploadStorage *storage, GroupItem GenericDirectUploadStep::statTree(const TreeStorage &storage, FilesToStat filesToStat, StatEndHandler statEndHandler) { - const auto setupHandler = [=](TaskTree &tree) { + const auto onSetup = [this, storage, filesToStat, statEndHandler](TaskTree &tree) { UploadStorage *storagePtr = storage.activeStorage(); const QList files = filesToStat(storagePtr); QList statList{finishAllAndDone, parallelLimit(MaxConcurrentStatCalls)}; @@ -161,7 +161,7 @@ GroupItem GenericDirectUploadStep::statTree(const TreeStorage &st } tree.setRecipe({statList}); }; - return TaskTreeTask(setupHandler); + return TaskTreeTask(onSetup); } GroupItem GenericDirectUploadStep::uploadTask(const TreeStorage &storage) @@ -225,7 +225,7 @@ GroupItem GenericDirectUploadStep::chmodTask(const DeployableFile &file) GroupItem GenericDirectUploadStep::chmodTree(const TreeStorage &storage) { - const auto setupChmodHandler = [=](TaskTree &tree) { + const auto onSetup = [this, storage](TaskTree &tree) { QList filesToChmod; for (const DeployableFile &file : std::as_const(storage->filesToUpload)) { if (file.isExecutable()) @@ -238,7 +238,7 @@ GroupItem GenericDirectUploadStep::chmodTree(const TreeStorage &s } tree.setRecipe({chmodList}); }; - return TaskTreeTask(setupChmodHandler); + return TaskTreeTask(onSetup); } GroupItem GenericDirectUploadStep::deployRecipe() diff --git a/src/plugins/remotelinux/killappstep.cpp b/src/plugins/remotelinux/killappstep.cpp index 020311e596f..0ccfe3ee743 100644 --- a/src/plugins/remotelinux/killappstep.cpp +++ b/src/plugins/remotelinux/killappstep.cpp @@ -55,7 +55,7 @@ GroupItem KillAppStep::deployRecipe() .arg(m_remoteExecutable.path())); return SetupResult::Continue; }; - const auto onDone = [this](const DeviceProcessKiller &, DoneWith result) { + const auto onDone = [this](DoneWith result) { const QString message = result == DoneWith::Success ? Tr::tr("Remote application killed.") : Tr::tr("Failed to kill remote application. Assuming it was not running."); addProgressMessage(message); diff --git a/src/plugins/remotelinux/tarpackagecreationstep.cpp b/src/plugins/remotelinux/tarpackagecreationstep.cpp index 6393197c5aa..52920b3ebc7 100644 --- a/src/plugins/remotelinux/tarpackagecreationstep.cpp +++ b/src/plugins/remotelinux/tarpackagecreationstep.cpp @@ -153,7 +153,7 @@ Tasking::GroupItem TarPackageCreationStep::runRecipe() async.setFutureSynchronizer(&m_synchronizer); return SetupResult::Continue; }; - const auto onDone = [this](const Async &, DoneWith result) { + const auto onDone = [this](DoneWith result) { if (result != DoneWith::Success) { emit addOutput(Tr::tr("Packaging failed."), OutputFormat::ErrorMessage); return; diff --git a/tests/auto/solutions/tasking/tst_tasking.cpp b/tests/auto/solutions/tasking/tst_tasking.cpp index cd015d12d67..cf315f84a98 100644 --- a/tests/auto/solutions/tasking/tst_tasking.cpp +++ b/tests/auto/solutions/tasking/tst_tasking.cpp @@ -80,14 +80,16 @@ void tst_Tasking::validConstructs() parallel, TestTask([](TaskObject &) {}, [](const TaskObject &, DoneWith) {}), TestTask([](TaskObject &) {}, [](const TaskObject &) {}), + TestTask([](TaskObject &) {}, [](DoneWith) {}), TestTask([](TaskObject &) {}, [] {}), TestTask([](TaskObject &) {}, {}), TestTask([](TaskObject &) {}), TestTask({}, [](const TaskObject &, DoneWith) {}), TestTask({}, [](const TaskObject &) {}), + TestTask({}, [](DoneWith) {}), TestTask({}, [] {}), TestTask({}, {}), - TestTask({}), + TestTask({}) }; const Group group1 { @@ -232,7 +234,7 @@ void tst_Tasking::testTree_data() }; const auto setupDone = [storage](int taskId, bool success = true) { - return [storage, taskId, success](const TaskObject &, DoneWith result) { + return [storage, taskId, success](DoneWith result) { const Handler handler = result == DoneWith::Cancel ? Handler::Canceled : success ? Handler::Success : Handler::Error; storage->m_log.append({taskId, handler});