From 6c98035c99700b4cd727fbf1158e346b9a02744c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 15 May 2013 08:18:05 -0600 Subject: QThreadPool: Fix regression from Qt 4 in dealing with priority starts The optimisation done in cbaf52b09971edf6f3e1458f7dd677b80a1568ed for Qt 5.0 got the order wrong of the comparison. The queue must be sorted in decreasing priority order. But since higher numbers mean higher priority, that means the queue must be sorted in decreasing priority number order. Task-number: QTBUG-29163 Change-Id: Iaf3424b9bb445bf5c71518927f37253cead454f3 Reviewed-by: Konstantin Ritt --- src/corelib/thread/qthreadpool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/thread') diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index 1616fb9fab..a7d52f9652 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -215,7 +215,7 @@ void QThreadPoolPrivate::enqueueTask(QRunnable *runnable, int priority) // put it on the queue QList >::const_iterator begin = queue.constBegin(); QList >::const_iterator it = queue.constEnd(); - if (it != begin && priority < (*(it - 1)).second) + if (it != begin && priority > (*(it - 1)).second) it = std::upper_bound(begin, --it, priority); queue.insert(it - begin, qMakePair(runnable, priority)); runnableReady.wakeOne(); -- cgit v1.2.3