diff options
author | Tianlu Shao <shaotianlu@uniontech.com> | 2021-12-17 10:27:55 +0800 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-12-20 13:18:26 +0100 |
commit | 87b93c29be02f0a7ff9424b5e2b6431e20bd4c40 (patch) | |
tree | 8063deab75bed4e1f420d669b734f7823847fee1 /tests/auto | |
parent | 43e9f86cc15fe5b394ee1690b302104118572fe1 (diff) |
QtConcurrent::run crashes on program exit
When an application is about to be closed and all the
destructors are called, if there isQtConcurrent::run on
the way, it crashes as the internal threadpool pointer
is nullptr.
Fixes: QTBUG-98901
Pick-to: 6.2 6.3
Change-Id: Idd84d1518fc6a225263e6666a0f1de2ccef79c82
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp index 235ffca0fc..0ff98c42f5 100644 --- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -65,6 +65,7 @@ private slots: void crefFunction(); void customPromise(); void nonDefaultConstructibleValue(); + void nullThreadPool(); }; void light() @@ -1577,5 +1578,16 @@ void tst_QtConcurrentRun::nonDefaultConstructibleValue() QCOMPARE(future.result().value, 42); } +// QTBUG-98901 +void tst_QtConcurrentRun::nullThreadPool() +{ + QThreadPool *pool = nullptr; + std::atomic<bool> isInvoked = false; + auto future = run(pool, [&] { isInvoked = true; }); + future.waitForFinished(); + QVERIFY(future.isCanceled()); + QVERIFY(!isInvoked); +} + QTEST_MAIN(tst_QtConcurrentRun) #include "tst_qtconcurrentrun.moc" |