From be8c257da9a264994243c120231965ff0008ef09 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 27 Jan 2020 13:19:00 +0100 Subject: [PATCH] QThread::setPriority() Warn about invalid parameter on all platforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit InheritPriority may not be set, but the warning only occurs on Windows. Move the warning to the public class. Change-Id: I51d401300f840e4c1396c2c30182e49ed45d60d2 Reviewed-by: Cristian Maureira-Fredes Reviewed-by: Christian Tismer Reviewed-by: David Faure Reviewed-by: MÃ¥rten Nordheim --- src/corelib/thread/qthread.cpp | 6 +++++- src/corelib/thread/qthread_win.cpp | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index d3bb372b007..d18056063f0 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -614,7 +614,7 @@ void QThread::run() priority. The \a priority argument can be any value in the \c - QThread::Priority enum except for \c InheritPriorty. + QThread::Priority enum except for \c InheritPriority. The effect of the \a priority parameter is dependent on the operating system's scheduling policy. In particular, the \a priority @@ -626,6 +626,10 @@ void QThread::run() */ void QThread::setPriority(Priority priority) { + if (priority == QThread::InheritPriority) { + qWarning("QThread::setPriority: Argument cannot be InheritPriority"); + return; + } Q_D(QThread); QMutexLocker locker(&d->mutex); if (!d->running) { diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 3df7080caf9..bc70e3178a2 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -715,9 +715,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority) prio = THREAD_PRIORITY_TIME_CRITICAL; break; - case QThread::InheritPriority: default: - qWarning("QThread::setPriority: Argument cannot be InheritPriority"); return; }