diff options
-rw-r--r-- | src/corelib/ipc/qsharedmemory_p.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qeventloop.h | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qiterable.h | 12 | ||||
-rw-r--r-- | src/corelib/tools/qarraydatapointer.h | 6 | ||||
-rw-r--r-- | src/corelib/tools/qtaggedpointer.h | 6 | ||||
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 2 | ||||
-rw-r--r-- | src/dbus/qdbusthreaddebug_p.h | 4 | ||||
-rw-r--r-- | src/plugins/platforms/directfb/qdirectfbconvenience.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.h | 2 |
9 files changed, 24 insertions, 15 deletions
diff --git a/src/corelib/ipc/qsharedmemory_p.h b/src/corelib/ipc/qsharedmemory_p.h index 3a6cd8c137..94194babf3 100644 --- a/src/corelib/ipc/qsharedmemory_p.h +++ b/src/corelib/ipc/qsharedmemory_p.h @@ -43,7 +43,7 @@ class QSharedMemoryLocker { public: - inline QSharedMemoryLocker(QSharedMemory *sharedMemory) : q_sm(sharedMemory) + Q_NODISCARD_CTOR QSharedMemoryLocker(QSharedMemory *sharedMemory) : q_sm(sharedMemory) { Q_ASSERT(q_sm); } diff --git a/src/corelib/kernel/qeventloop.h b/src/corelib/kernel/qeventloop.h index 1da1d2336e..387fcbbeaa 100644 --- a/src/corelib/kernel/qeventloop.h +++ b/src/corelib/kernel/qeventloop.h @@ -54,8 +54,11 @@ class QEventLoopLockerPrivate; class Q_CORE_EXPORT QEventLoopLocker { public: + Q_NODISCARD_CTOR QEventLoopLocker(); + Q_NODISCARD_CTOR explicit QEventLoopLocker(QEventLoop *loop); + Q_NODISCARD_CTOR explicit QEventLoopLocker(QThread *thread); ~QEventLoopLocker(); diff --git a/src/corelib/kernel/qiterable.h b/src/corelib/kernel/qiterable.h index 11bf82dc04..1178c5e8a3 100644 --- a/src/corelib/kernel/qiterable.h +++ b/src/corelib/kernel/qiterable.h @@ -19,16 +19,16 @@ namespace QtPrivate { QTaggedPointer<Storage, Tag> m_pointer; public: - QConstPreservingPointer(std::nullptr_t) : m_pointer(nullptr, Const) {} + Q_NODISCARD_CTOR QConstPreservingPointer(std::nullptr_t) : m_pointer(nullptr, Const) {} - QConstPreservingPointer(const void *pointer, qsizetype alignment) + Q_NODISCARD_CTOR QConstPreservingPointer(const void *pointer, qsizetype alignment) : m_pointer(reinterpret_cast<Storage *>(const_cast<void *>(pointer)), Const) { Q_UNUSED(alignment); Q_ASSERT(alignment > qsizetype(alignof(Storage))); } - QConstPreservingPointer(void *pointer, qsizetype alignment) + Q_NODISCARD_CTOR QConstPreservingPointer(void *pointer, qsizetype alignment) : m_pointer(reinterpret_cast<Storage *>(pointer), Mutable) { Q_UNUSED(alignment); @@ -36,20 +36,20 @@ namespace QtPrivate { } template<typename InputType> - QConstPreservingPointer(const InputType *pointer) + Q_NODISCARD_CTOR QConstPreservingPointer(const InputType *pointer) : m_pointer(reinterpret_cast<Storage *>(const_cast<InputType *>(pointer)), Const) { static_assert(alignof(InputType) >= alignof(Storage)); } template<typename InputType> - QConstPreservingPointer(InputType *pointer) + Q_NODISCARD_CTOR QConstPreservingPointer(InputType *pointer) : m_pointer(reinterpret_cast<Storage *>(pointer), Mutable) { static_assert(alignof(InputType) >= alignof(Storage)); } - QConstPreservingPointer() = default; + Q_NODISCARD_CTOR QConstPreservingPointer() = default; const Type *constPointer() const { diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index eb20330f0f..258e7b7446 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -27,27 +27,32 @@ public: typedef typename std::conditional<pass_parameter_by_value, T, const T &>::type parameter_type; + Q_NODISCARD_CTOR constexpr QArrayDataPointer() noexcept : d(nullptr), ptr(nullptr), size(0) { } + Q_NODISCARD_CTOR QArrayDataPointer(const QArrayDataPointer &other) noexcept : d(other.d), ptr(other.ptr), size(other.size) { ref(); } + Q_NODISCARD_CTOR constexpr QArrayDataPointer(Data *header, T *adata, qsizetype n = 0) noexcept : d(header), ptr(adata), size(n) { } + Q_NODISCARD_CTOR explicit QArrayDataPointer(QPair<QTypedArrayData<T> *, T *> adata, qsizetype n = 0) noexcept : d(adata.first), ptr(adata.second), size(n) { } + Q_NODISCARD_CTOR static QArrayDataPointer fromRawData(const T *rawData, qsizetype length) noexcept { Q_ASSERT(rawData || !length); @@ -61,6 +66,7 @@ public: return *this; } + Q_NODISCARD_CTOR QArrayDataPointer(QArrayDataPointer &&other) noexcept : d(other.d), ptr(other.ptr), size(other.size) { diff --git a/src/corelib/tools/qtaggedpointer.h b/src/corelib/tools/qtaggedpointer.h index bc43f765aa..6c467d59f8 100644 --- a/src/corelib/tools/qtaggedpointer.h +++ b/src/corelib/tools/qtaggedpointer.h @@ -43,10 +43,10 @@ public: static constexpr quintptr tagMask() { return QtPrivate::TagInfo<T>::alignment - 1; } static constexpr quintptr pointerMask() { return ~tagMask(); } - constexpr QTaggedPointer() noexcept : d(0) {} - constexpr QTaggedPointer(std::nullptr_t) noexcept : QTaggedPointer() {} + Q_NODISCARD_CTOR constexpr QTaggedPointer() noexcept : d(0) {} + Q_NODISCARD_CTOR constexpr QTaggedPointer(std::nullptr_t) noexcept : QTaggedPointer() {} - explicit QTaggedPointer(T *pointer, Tag tag = Tag()) noexcept + Q_NODISCARD_CTOR explicit QTaggedPointer(T *pointer, Tag tag = Tag()) noexcept : d(quintptr(pointer) | quintptr(tag)) { static_assert(sizeof(Type*) == sizeof(QTaggedPointer)); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 4d67875c75..c978252efe 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1944,7 +1944,7 @@ bool QDBusConnectionPrivate::send(const QDBusMessage& message) class QDBusBlockingCallWatcher { public: - QDBusBlockingCallWatcher(const QDBusMessage &message) + Q_NODISCARD_CTOR QDBusBlockingCallWatcher(const QDBusMessage &message) : m_message(message), m_maxCallTimeoutMs(0) { #if defined(QT_NO_DEBUG) diff --git a/src/dbus/qdbusthreaddebug_p.h b/src/dbus/qdbusthreaddebug_p.h index 73be3d7517..a1d3a420ec 100644 --- a/src/dbus/qdbusthreaddebug_p.h +++ b/src/dbus/qdbusthreaddebug_p.h @@ -93,7 +93,7 @@ struct QDBusReadLocker: QDBusLockerBase { QDBusConnectionPrivate *self; ThreadAction action; - inline QDBusReadLocker(ThreadAction a, QDBusConnectionPrivate *s) + Q_NODISCARD_CTOR QDBusReadLocker(ThreadAction a, QDBusConnectionPrivate *s) : self(s), action(a) { reportThreadAction(action, BeforeLock, self); @@ -113,7 +113,7 @@ struct QDBusWriteLocker: QDBusLockerBase { QDBusConnectionPrivate *self; ThreadAction action; - inline QDBusWriteLocker(ThreadAction a, QDBusConnectionPrivate *s) + Q_NODISCARD_CTOR QDBusWriteLocker(ThreadAction a, QDBusConnectionPrivate *s) : self(s), action(a) { reportThreadAction(action, BeforeLock, self); diff --git a/src/plugins/platforms/directfb/qdirectfbconvenience.h b/src/plugins/platforms/directfb/qdirectfbconvenience.h index c013988fe2..dc657f384e 100644 --- a/src/plugins/platforms/directfb/qdirectfbconvenience.h +++ b/src/plugins/platforms/directfb/qdirectfbconvenience.h @@ -62,7 +62,7 @@ template <typename T> class QDirectFBPointer : public QScopedPointer<T, QDirectFBInterfaceCleanupHandler<T> > { public: - QDirectFBPointer(T *t = nullptr) + Q_NODISCARD_CTOR QDirectFBPointer(T *t = nullptr) : QScopedPointer<T, QDirectFBInterfaceCleanupHandler<T> >(t) {} diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 24e684866d..abc17b210e 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -367,7 +367,7 @@ Q_DECLARE_TYPEINFO(QXcbConnection::TabletData, Q_RELOCATABLE_TYPE); class QXcbConnectionGrabber { public: - QXcbConnectionGrabber(QXcbConnection *connection); + Q_NODISCARD_CTOR QXcbConnectionGrabber(QXcbConnection *connection); ~QXcbConnectionGrabber(); void release(); private: |