diff options
| author | Thiago Macieira <thiago.macieira@intel.com> | 2024-09-10 10:22:16 -0700 |
|---|---|---|
| committer | Thiago Macieira <thiago.macieira@intel.com> | 2024-10-04 10:44:56 -0700 |
| commit | 39bb305416dd89785af431d76a08154f246c34f6 (patch) | |
| tree | 024f654a4857f73afe6585afa8e5966712edecd8 /src/corelib/kernel/qmetaobjectbuilder.cpp | |
| parent | 4f47ee4de46f1fa2df9fef163590807e2fae28d1 (diff) | |
moc: deprecate use of int to return QFlags values
This code appears to be legacy from Qt 3's way of handling properties of
enum types, because back then there was no QFlags and QVariant had a
limited set of types it could use. To support flags and enum types,
QObject::property() and setProperty() were coded to pass ints if the
property had the isEnumType() flag set. This code was ported to the new
(static) QMetaObject format in Qt 4 before QVariant gained support for
user types. When QVariant gained support for user types, support for
enums was changed to use the actual enum type in the property accessors,
which compiles for non-scoped enums (C++11).
This commit causes such code to produce a warning, to warn users that
they need to update their API. I have found no use of this in Qt or Qt
Creator code, but users may have something ported from Qt 3 that simply
still worked. We do have one setter taking int in QtWidgets
(QGroupBox::setAlignment), which isn't getting deprecated by this change
because QFlags can still be constructed (without warning) from integers,
through QFlag.
GCC warning:
qtmochelpers.h: In instantiation of ‘std::enable_if_t<...> QtMocHelpers::assignFlags(void*, I) [with ...]’:
moc_flags-property-integer-access.cpp:92:49: required from here
uint from a Q_PROPERTY that is a Q_FLAG is deprecated; please update to return the actual property's type [-Wdeprecated-declarations]
qtmochelpers.h:104:13: note: declared here
Clang warning:
qtmochelpers.h:113:5: warning: 'assignFlagsFromInteger<ClassWithFlagsAccessAsInteger::Flag>' is deprecated: Returning int/uint from a Q_PROPERTY that is a Q_FLAG is deprecated; please update to return the actual property's type [-Wdeprecated-declarations]
moc_flags-property-integer-access.cpp:92:31: note: in instantiation of function template specialization 'QtMocHelpers::assignFlags<QFlags<ClassWithFlagsAccessAsInteger::Flag>, unsigned int>' requested here
See-also: https://lists.qt-project.org/pipermail/development/2024-September/045636.html
Change-Id: I526db07389040483fc2efffd66895430a55ec62b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetaobjectbuilder.cpp')
0 files changed, 0 insertions, 0 deletions
