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>
This commit is contained in:
parent
81054b117b
commit
36640aa0af
@ -1046,6 +1046,16 @@ int QMetaType::registerNormalizedType(const NS(QByteArray) &normalizedTypeName,
|
|||||||
if (idx >= User) {
|
if (idx >= User) {
|
||||||
previousSize = ct->at(idx - User).size;
|
previousSize = ct->at(idx - User).size;
|
||||||
previousFlags = ct->at(idx - User).flags;
|
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);
|
normalizedTypeName.constData(), idx, previousSize, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do not compare types higher than 0x100:
|
||||||
// Ignore WasDeclaredAsMetaType inconsitency, to many users were hitting the problem
|
// Ignore WasDeclaredAsMetaType inconsitency, to many users were hitting the problem
|
||||||
previousFlags |= WasDeclaredAsMetaType;
|
// Ignore IsGadget as it was added in Qt 5.5
|
||||||
flags |= WasDeclaredAsMetaType;
|
// Ignore all the future flags as well
|
||||||
|
if ((previousFlags ^ flags) & 0xff) {
|
||||||
if (previousFlags != flags) {
|
|
||||||
const int maskForTypeInfo = NeedsConstruction | NeedsDestruction | MovableType;
|
const int maskForTypeInfo = NeedsConstruction | NeedsDestruction | MovableType;
|
||||||
const char *msg = "QMetaType::registerType: Binary compatibility break. "
|
const char *msg = "QMetaType::registerType: Binary compatibility break. "
|
||||||
"\nType flags for type '%s' [%i] don't match. Previously "
|
"\nType flags for type '%s' [%i] don't match. Previously "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user