From c32576642323e2a957dc12abd89b61022ad594f8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 13 Jun 2023 09:34:12 +0200 Subject: [PATCH] QSignalBlocker: plaster with [[nodiscard]] It's a RAII class, and RAII classes should be marked [[nodiscard]] at the class as well as the ctor level. Task-number: QTBUG-104164 Change-Id: I77260dc00d51d62ed1064e13f566d04e88d28ef9 Reviewed-by: Fabian Kosmale (cherry picked from commit 16a19a4f4ab207eba4ba6da987b31628b51903b0) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qobject.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 3c102a0a851..49435b97016 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -436,13 +436,16 @@ inline QBindingStorage *qGetBindingStorage(QObject *o) Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *); #endif -class QSignalBlocker +class [[nodiscard]] QSignalBlocker { public: + Q_NODISCARD_CTOR inline explicit QSignalBlocker(QObject *o) noexcept; + Q_NODISCARD_CTOR inline explicit QSignalBlocker(QObject &o) noexcept; inline ~QSignalBlocker(); + Q_NODISCARD_CTOR inline QSignalBlocker(QSignalBlocker &&other) noexcept; inline QSignalBlocker &operator=(QSignalBlocker &&other) noexcept;