From d598066dcfdb8a8330f9df029172188d2296fed7 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 21 May 2021 12:04:16 +0200 Subject: [PATCH] QFutureInterface(Base): code tidies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refT()/derefT() can be marked noexcept; we don't care about not overflowing the refcounter as a precondition. (This is BC, as no compiler mangles noexcept.) This in turn allows to mark a constructor calling refT() as noexcept. Driveby: mark also the same functions to not be `const` in Qt 7. They clearly are meant to modify *this, and constness only works because of the unmanaged (raw) d-pointer. Change-Id: I8d7d365640ff2e1cedc0a234c9abccdfc95ba6e3 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Andrei Golubev Reviewed-by: Sona Kurazyan --- src/corelib/thread/qfutureinterface.cpp | 4 ++-- src/corelib/thread/qfutureinterface.h | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index 89062451911..9bb7d505e25 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -586,12 +586,12 @@ void QFutureInterfaceBase::swap(QFutureInterfaceBase &other) noexcept qSwap(d, other.d); } -bool QFutureInterfaceBase::refT() const +bool QFutureInterfaceBase::refT() const noexcept { return d->refCount.refT(); } -bool QFutureInterfaceBase::derefT() const +bool QFutureInterfaceBase::derefT() const noexcept { // Called from ~QFutureInterface return !d || d->refCount.derefT(); diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h index 6df15304fc6..3a6fe86d76c 100644 --- a/src/corelib/thread/qfutureinterface.h +++ b/src/corelib/thread/qfutureinterface.h @@ -178,8 +178,9 @@ public: void swap(QFutureInterfaceBase &other) noexcept; protected: - bool refT() const; - bool derefT() const; + // ### Qt 7: remove const from refT/derefT + bool refT() const noexcept; + bool derefT() const noexcept; void reset(); void rethrowPossibleException(); public: @@ -234,7 +235,7 @@ public: refT(); } QFutureInterface(const QFutureInterfaceBase &dd) : QFutureInterfaceBase(dd) { refT(); } - QFutureInterface(QFutureInterfaceBase &&dd) : QFutureInterfaceBase(std::move(dd)) { refT(); } + QFutureInterface(QFutureInterfaceBase &&dd) noexcept : QFutureInterfaceBase(std::move(dd)) { refT(); } QFutureInterface &operator=(const QFutureInterface &other) { QFutureInterface copy(other);