diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-06-03 15:28:01 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@theqtcompany.com> | 2015-06-10 05:29:22 +0000 |
commit | 36640aa0afb722479ba47d6fbd9401c433dead41 (patch) | |
tree | a177fb5977c0f5450a8d1f6e3ace5be24b6475a3 /src | |
parent | 81054b117b5a3d0d9e4d17a531b453515410432b (diff) |
Don't enforce all QMetaType::TypeFlag difference across Qt versions
QMetaType::IsGadget was introduced in Qt 5.5 and set when Q_GADGET is used.
If an existing Qt 5.4 class was converted to a gadget in Qt 5.5+,
the two types would have differing QMetaType::TypeFlags. Such a conversion
happened for QGeoCoordinate, QGeoShape, QGeoRectangle
and QGeoCircle. There might be other classes too.
In principle, the same problem exists for every future addition to
QMetaType::TypeFlag too. This patch ensures that new flags are kept in
the metatype database and the related qFatal call is not triggered for any
flag >= TypeFlag::WasDeclaredAsMetaType.
Change-Id: Ibb15daeb28d9a11b7f31658f4219cbca2499213f
Task-number: QTBUG-46454
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qmetatype.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 3b70ef92ed..0f9cf41b77 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1046,6 +1046,16 @@ int QMetaType::registerNormalizedType(const NS(QByteArray) &normalizedTypeName, if (idx >= User) { previousSize = ct->at(idx - User).size; previousFlags = ct->at(idx - User).flags; + + // Set new/additional flags in case of old library/app. + // Ensures that older code works in conjunction with new Qt releases + // requiring the new flags. + if (flags != previousFlags) { + QCustomTypeInfo &inf = ct->data()[idx - User]; + inf.flags |= flags; + if (metaObject) + inf.metaObject = metaObject; + } } } @@ -1061,11 +1071,11 @@ int QMetaType::registerNormalizedType(const NS(QByteArray) &normalizedTypeName, normalizedTypeName.constData(), idx, previousSize, size); } + // Do not compare types higher than 0x100: // Ignore WasDeclaredAsMetaType inconsitency, to many users were hitting the problem - previousFlags |= WasDeclaredAsMetaType; - flags |= WasDeclaredAsMetaType; - - if (previousFlags != flags) { + // Ignore IsGadget as it was added in Qt 5.5 + // Ignore all the future flags as well + if ((previousFlags ^ flags) & 0xff) { const int maskForTypeInfo = NeedsConstruction | NeedsDestruction | MovableType; const char *msg = "QMetaType::registerType: Binary compatibility break. " "\nType flags for type '%s' [%i] don't match. Previously " |