From baa44b9ddfa0fe92275ff4f27d7f2b1a9be10486 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 26 Mar 2024 10:39:43 +0800 Subject: Qt::ApplicationAttribute: static_assert that we don't go higher than 32 Because we can't support it on 32 bit operating systems. Task-number: QTBUG-69558 Change-Id: I406ecccdf039d7d4f4c24268c92c91e367655cba Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcoreapplication.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 7e6f21e8a6..2244f976a4 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1022,7 +1022,6 @@ bool QCoreApplication::isSetuidAllowed() return QCoreApplicationPrivate::setuidAllowed; } - /*! Sets the attribute \a attribute if \a on is true; otherwise clears the attribute. @@ -1035,6 +1034,10 @@ bool QCoreApplication::isSetuidAllowed() */ void QCoreApplication::setAttribute(Qt::ApplicationAttribute attribute, bool on) { + // Since we bit-shift these values, we can't go higher than 32 on 32 bit operating systems + // without changing the storage type of QCoreApplicationPrivate::attribs to quint64. + static_assert(Qt::AA_AttributeCount <= sizeof(QCoreApplicationPrivate::attribs) * CHAR_BIT); + if (on) QCoreApplicationPrivate::attribs |= 1 << attribute; else -- cgit v1.2.3