diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index ea76a2ccada..738c3846c53 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -438,7 +438,7 @@ QThread *QThread::currentThread() \sa currentThread(), QCoreApplication::instance() */ -bool QThread::isMainThread() +bool QThread::isMainThread() noexcept { return currentThreadId() == QCoreApplicationPrivate::theMainThreadId.loadRelaxed(); } @@ -952,7 +952,7 @@ int QThread::loopLevel() const therefore give surprising results if it outlives the QThread object (threads claimed to be the same even if they aren't). */ -Qt::HANDLE QThreadPrivate::threadId() const +Qt::HANDLE QThreadPrivate::threadId() const noexcept { return data->threadId.loadRelaxed(); } @@ -963,7 +963,7 @@ Qt::HANDLE QThreadPrivate::threadId() const \sa currentThreadId() */ -bool QThread::isCurrentThread() const +bool QThread::isCurrentThread() const noexcept { Q_D(const QThread); return QThread::currentThreadId() == d->threadId(); @@ -1041,7 +1041,7 @@ QThread *QThread::currentThread() return QThreadData::current()->thread.loadAcquire(); } -bool QThread::isCurrentThread() const +bool QThread::isCurrentThread() const noexcept { return true; } diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 641c8ef68a0..ae060ecf1cf 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -30,7 +30,7 @@ class Q_CORE_EXPORT QThread : public QObject public: static Qt::HANDLE currentThreadId() noexcept Q_DECL_PURE_FUNCTION; static QThread *currentThread(); - static bool isMainThread(); + static bool isMainThread() noexcept; static int idealThreadCount() noexcept; static void yieldCurrentThread(); @@ -69,7 +69,7 @@ public: bool event(QEvent *event) override; int loopLevel() const; - bool isCurrentThread() const; + bool isCurrentThread() const noexcept; template [[nodiscard]] static QThread *create(Function &&f, Args &&... args); diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index c39e21ec9a2..d6fd99e5ba2 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -179,7 +179,7 @@ public: ~QThreadPrivate(); void setPriority(QThread::Priority prio); - Qt::HANDLE threadId() const; + Qt::HANDLE threadId() const noexcept; mutable QMutex mutex; QAtomicInt quitLockRef;