diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2023-02-21 12:05:18 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2023-02-24 12:48:44 +0000 |
commit | 8eaf73700ecd0cd1f30b9973cb8b2ae0bc4bc52c (patch) | |
tree | 812b88253aa21cc4db4769eed2ed177bb1b74b68 /tests | |
parent | 97b97825edf69b9a778e3eaefb11de1aee34d21c (diff) |
TaskTree: Don't call storage done handlers from TaskTree's d'tor
Change-Id: Ie2b04d433be3452f9e668efd3341dedfcb154290
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/utils/tasktree/tst_tasktree.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/tests/auto/utils/tasktree/tst_tasktree.cpp b/tests/auto/utils/tasktree/tst_tasktree.cpp index 3e5c67050f5..43bf0468c5d 100644 --- a/tests/auto/utils/tasktree/tst_tasktree.cpp +++ b/tests/auto/utils/tasktree/tst_tasktree.cpp @@ -1054,26 +1054,40 @@ void tst_TaskTree::storageOperators() } // This test checks whether a running task tree may be safely destructed. -// It also checks whether destructor of task tree deletes properly the storage created -// while starting the task tree. +// It also checks whether the destructor of a task tree deletes properly the storage created +// while starting the task tree. When running task tree is destructed, the storage done +// handler shouldn't be invoked. void tst_TaskTree::storageDestructor() { + bool setupCalled = false; + const auto setupHandler = [&setupCalled](CustomStorage *) { + setupCalled = true; + }; + bool doneCalled = false; + const auto doneHandler = [&doneCalled](CustomStorage *) { + doneCalled = true; + }; QCOMPARE(CustomStorage::instanceCount(), 0); { + TreeStorage<CustomStorage> storage; const auto setupProcess = [testAppPath = m_testAppPath](QtcProcess &process) { process.setCommand(CommandLine(testAppPath, {"-sleep", "1000"})); }; const Group root { - Storage(TreeStorage<CustomStorage>()), + Storage(storage), Process(setupProcess) }; - TaskTree processTree(root); + TaskTree taskTree(root); QCOMPARE(CustomStorage::instanceCount(), 0); - processTree.start(); + taskTree.onStorageSetup(storage, setupHandler); + taskTree.onStorageDone(storage, doneHandler); + taskTree.start(); QCOMPARE(CustomStorage::instanceCount(), 1); } QCOMPARE(CustomStorage::instanceCount(), 0); + QVERIFY(setupCalled); + QVERIFY(!doneCalled); } QTEST_GUILESS_MAIN(tst_TaskTree) |