diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index 4c705f5a93..a923b8aa41 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -269,9 +269,9 @@ void QThreadPoolPrivate::reset() runnableReady.wakeAll(); while (!allThreads.empty()) { - // make a copy of the set so that we can iterate without the lock - QSet allThreadsCopy = allThreads; - allThreads.clear(); + // move the contents of the set out so that we can iterate without the lock + QSet allThreadsCopy; + allThreadsCopy.swap(allThreads); locker.unlock(); foreach (QThreadPoolThread *thread, allThreadsCopy) {