From 197a45b9b964c695983ad711c61f60f166742902 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 31 Aug 2023 18:31:34 +0200 Subject: [PATCH] TaskTree: Change the signature of storage handlers The handlers for TaskTree::onStorage{Setup,Done}(...) took a pointer to the storage struct. Take a reference instead. This is in line with tasks setup/done/error handlers. Change-Id: I8ff18c250f0fbbcd8210ec304e34232e842831fc Reviewed-by: hjk Reviewed-by: --- src/libs/solutions/tasking/tasktree.h | 2 +- tests/auto/solutions/tasking/tst_tasking.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/solutions/tasking/tasktree.h b/src/libs/solutions/tasking/tasktree.h index df26596d027..32252bcc83b 100644 --- a/src/libs/solutions/tasking/tasktree.h +++ b/src/libs/solutions/tasking/tasktree.h @@ -437,7 +437,7 @@ private: StorageVoidHandler wrapHandler(StorageHandler &&handler) { return [=](void *voidStruct) { StorageStruct *storageStruct = static_cast(voidStruct); - std::invoke(handler, storageStruct); + std::invoke(handler, *storageStruct); }; } diff --git a/tests/auto/solutions/tasking/tst_tasking.cpp b/tests/auto/solutions/tasking/tst_tasking.cpp index e73589499f8..63302c6dc31 100644 --- a/tests/auto/solutions/tasking/tst_tasking.cpp +++ b/tests/auto/solutions/tasking/tst_tasking.cpp @@ -550,8 +550,8 @@ void tst_Tasking::testTree_data() }; taskTree.setRecipe(nestedRoot); CustomStorage *activeStorage = storage.activeStorage(); - auto collectSubLog = [activeStorage](CustomStorage *subTreeStorage){ - activeStorage->m_log += subTreeStorage->m_log; + const auto collectSubLog = [activeStorage](CustomStorage &subTreeStorage){ + activeStorage->m_log += subTreeStorage.m_log; }; taskTree.onStorageDone(storage, collectSubLog); }; @@ -2244,7 +2244,7 @@ void tst_Tasking::testTree() TaskTree taskTree({testData.root.withTimeout(1000ms)}); QCOMPARE(taskTree.taskCount() - 1, testData.taskCount); // -1 for the timeout task above Log actualLog; - const auto collectLog = [&actualLog](CustomStorage *storage) { actualLog = storage->m_log; }; + const auto collectLog = [&actualLog](CustomStorage &storage) { actualLog = storage.m_log; }; taskTree.onStorageDone(testData.storage, collectLog); const OnDone result = taskTree.runBlocking() ? OnDone::Success : OnDone::Failure; QCOMPARE(taskTree.isRunning(), false); @@ -2274,11 +2274,11 @@ void tst_Tasking::storageOperators() void tst_Tasking::storageDestructor() { bool setupCalled = false; - const auto setupHandler = [&setupCalled](CustomStorage *) { + const auto setupHandler = [&setupCalled](CustomStorage &) { setupCalled = true; }; bool doneCalled = false; - const auto doneHandler = [&doneCalled](CustomStorage *) { + const auto doneHandler = [&doneCalled](CustomStorage &) { doneCalled = true; }; QCOMPARE(CustomStorage::instanceCount(), 0);