From c0d310d9969111713ec705db1c6c4833c92df468 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 21 Apr 2021 17:51:01 -0700 Subject: QThreadPool: obey the docs that say we always use at least 1 thread Even if the user (usually accidentally) sets a thread count of zero or negative. The reporter in the bug report did QThread::idealThreadCount() - 1 on a 1 CPU system... Drive-by add to the documentation and the missing #include. Fixes: QTBUG-93007 Change-Id: I6cdea00671e8479b9c50fffd167807d14e030154 Reviewed-by: Samuel Gaist Reviewed-by: Sona Kurazyan (cherry picked from commit 885eff053797d56f2e295558d0a71b030fbb1a69) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index e6db963c7b..362faf9e1d 100644 --- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -483,7 +483,7 @@ void tst_QThreadPool::setMaxThreadCountStartsAndStopsThreads() }; QThreadPool threadPool; - threadPool.setMaxThreadCount(1); + threadPool.setMaxThreadCount(-1); // docs say we'll always start at least one WaitingTask *task = new WaitingTask; threadPool.start(task); -- cgit v1.2.3