summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-01-10 17:38:55 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-01-22 17:21:35 +0000
commit4faf011c3f5f4a739f4ddc54040b5319f7fe5d90 (patch)
treea391722fa37ea521930f0cceaa50d475fd166844 /src/corelib/kernel
parent730f0df17db53b249b8680a14c40d12107c8e24e (diff)
Document that you shouldn't Q_ENUM() things outside the int range
The meta object system stores enums as signed int, probably for performance reasons. This is good enough for about 99% of the use cases. If you try to register larger types and then access them through the metaobject system, you can get undefined behavior. Task-number: QTBUG-71947 Change-Id: I16b395547c22fad10b476c2c2a0768538db0a20e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qobject.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 4680742a3e..42c39f18e3 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4338,6 +4338,12 @@ QDebug operator<<(QDebug dbg, const QObject *o)
in a QVariant, you can convert them to strings. Likewise, passing them to
QDebug will print out their names.
+ Mind that the enum values are stored as signed \c int in the meta object system.
+ Registering enumerations with values outside the range of values valid for \c int
+ will lead to overflows and potentially undefined behavior when accessing them through
+ the meta object system. QML, for example, does access registered enumerations through
+ the meta object system.
+
\sa {Qt's Property System}
*/
@@ -4389,6 +4395,12 @@ QDebug operator<<(QDebug dbg, const QObject *o)
used in a QVariant, you can convert them to strings. Likewise, passing them
to QDebug will print out their names.
+ Mind that the enum values are stored as signed \c int in the meta object system.
+ Registering enumerations with values outside the range of values valid for \c int
+ will lead to overflows and potentially undefined behavior when accessing them through
+ the meta object system. QML, for example, does access registered enumerations through
+ the meta object system.
+
\sa {Qt's Property System}
*/