cause an abort().
+- QVariant
+
+ * Definition of QVariant::UserType changed. Currently it is the same as
+ QMetaType::User, which means that it points to the first registered custom
+ type, instead of a nonexistent type.
+
+
- QMessageBox
* The static function QMessageBox::question has changed the default argument
t = QMetaType::type(typeName);
if (t == QVariant::Invalid)
t = QVariant::nameToType(typeName);
- if (t == QVariant::Invalid || t == QVariant::UserType) {
- if (t == QVariant::Invalid)
- qWarning("QMetaProperty::read: Unable to handle unregistered datatype '%s' for property '%s::%s'", typeName, mobj->className(), name());
+ if (t == QVariant::Invalid) {
+ qWarning("QMetaProperty::read: Unable to handle unregistered datatype '%s' for property '%s::%s'", typeName, mobj->className(), name());
return QVariant();
}
}
return Invalid;
int metaType = QMetaType::type(name);
- return metaType <= int(LastGuiType) ? QVariant::Type(metaType) : UserType;
+ return metaType <= int(UserType) ? QVariant::Type(metaType) : UserType;
}
#ifndef QT_NO_DATASTREAM
return;
typeId = mapIdFromQt3ToCurrent[typeId];
} else if (s.version() < QDataStream::Qt_5_0) {
- if (typeId >= 128 && typeId != QVariant::UserType) {
+ if (typeId == 127 /* QVariant::UserType */) {
+ typeId = QMetaType::User;
+ } else if (typeId >= 128 && typeId != QVariant::UserType) {
// In Qt4 id == 128 was FirstExtCoreType. In Qt5 ExtCoreTypes set was merged to CoreTypes
// by moving all ids down by 97.
typeId -= 97;
return;
}
} else if (s.version() < QDataStream::Qt_5_0) {
- if (typeId >= 128 - 97 && typeId <= LastCoreType) {
+ if (typeId == QMetaType::User) {
+ typeId = 127; // QVariant::UserType had this value in Qt4
+ } else if (typeId >= 128 - 97 && typeId <= LastCoreType) {
// In Qt4 id == 128 was FirstExtCoreType. In Qt5 ExtCoreTypes set was merged to CoreTypes
// by moving all ids down by 97.
typeId += 97;
s << typeId;
if (s.version() >= QDataStream::Qt_4_2)
s << qint8(d.is_null);
- if (typeId == QVariant::UserType) {
+ if (d.type >= QVariant::UserType) {
s << QMetaType::typeName(userType());
}
Icon = QMetaType::QIcon,
SizePolicy = QMetaType::QSizePolicy,
- UserType = 127,
+ UserType = QMetaType::User,
LastType = 0xffffffff // need this so that gcc >= 3.4 allocates 32 bits for Type
};
void delegate(const QMetaTypeSwitcher::UnknownType*)
{
- if (m_x->type == QVariant::UserType) {
- // TODO get rid of it
- // And yes! we can support historical magic, unkonwn/unconstructed user type isn't that
- // awesome? this QVariant::isValid will be true!
- m_x->is_null = !m_copy;
- m_x->is_shared = false;
- return;
- }
qWarning("Trying to construct an instance of an invalid type, type id: %i", m_x->type);
m_x->type = QVariant::Invalid;
}
void delegate(const QMetaTypeSwitcher::UnknownType*)
{
- if (m_d->type == QVariant::UserType)
- return;
qWarning("Trying to destruct an instance of an invalid type, type id: %i", m_d->type);
}
// Ignore nonconstructible type
void delegate(const QMetaTypeSwitcher::UnknownType*)
{
- if (m_d->type == QVariant::UserType)
- m_debugStream.nospace() << "QVariant::UserType";
- else
- qWarning("Trying to stream an instance of an invalid type, type id: %i", m_d->type);
+ qWarning("Trying to stream an instance of an invalid type, type id: %i", m_d->type);
}
void delegate(const void*)
{
QVERIFY(!property.isEnumType());
QCOMPARE(property.typeName(), "CustomType*");
QCOMPARE(property.type(), QVariant::UserType);
+ QCOMPARE(property.userType(), qMetaTypeId<CustomType*>());
CustomType *customPointer = 0;
QVariant customVariant = object.property("custom");
QVERIFY(property.isWritable());
QCOMPARE(property.typeName(), "CustomType*");
QCOMPARE(property.type(), QVariant::UserType);
+ QCOMPARE(property.userType(), qMetaTypeId<CustomType*>());
QVERIFY(object.setProperty("custom", customVariant));
QCOMPARE(object.custom(), customPointer);
QTest::newRow("HashSecondLarger") << QVariant(hash1) << QVariant(hash2) << false;
}
-
- QTest::newRow( "UserType" ) << QVariant(QVariant::UserType) << QVariant(QVariant::UserType) << true;
- QVariant mUserType(QVariant::UserType);
- QTest::newRow( "Shared UserType" ) << mUserType << mUserType << true;
}
void tst_QVariant::operator_eq_eq()
QTest::newRow("39") << int(QVariant::RectF) << QByteArray("QRectF");
QTest::newRow("40") << int(QVariant::PointF) << QByteArray("QPointF");
QTest::newRow("41") << int(QVariant::RegExp) << QByteArray("QRegExp");
- QTest::newRow("42") << int(QVariant::UserType) << QByteArray();
QTest::newRow("43") << int(QVariant::Matrix) << QByteArray("QMatrix");
QTest::newRow("44") << int(QVariant::Transform) << QByteArray("QTransform");
QTest::newRow("45") << int(QVariant::Hash) << QByteArray("QVariantHash");
qVariantSetValue(userVar, data);
QCOMPARE(userVar.type(), QVariant::UserType);
+ QCOMPARE(userVar.userType(), qMetaTypeId<MyType>());
QCOMPARE(userVar.typeName(), "MyType");
QVERIFY(!userVar.isNull());
QVERIFY(!userVar.canConvert(QVariant::String));
- QVERIFY(!userVar.canConvert(QVariant::UserType));
QVariant userVar2(userVar);
QVERIFY(userVar == userVar2);
qVariantSetValue(userVar, &data);
QCOMPARE(userVar.type(), QVariant::UserType);
+ QCOMPARE(userVar.userType(), qMetaTypeId<MyType*>());
QCOMPARE(userVar.typeName(), "MyType*");
QVERIFY(!userVar.isNull());
QVERIFY(!userVar.canConvert(QVariant::String));
- QVERIFY(!userVar.canConvert(QVariant::UserType));
QVariant userVar2(userVar);
QVERIFY(userVar == userVar2);
void tst_QVariant::loadUnknownUserType()
{
qRegisterMetaType<MyClass>("MyClass");
- char data[] = {0, 0, 0, 127, 0, 0, 0, 0, 8, 77, 121, 67, 108, 97, 115, 115, 0};
+ char data[] = {0, 0, 1, 0, 0, 0, 0, 0, 8, 77, 121, 67, 108, 97, 115, 115, 0};
QByteArray ba(data, sizeof(data));
QDataStream ds(&ba, QIODevice::ReadOnly);
memcpy(buffer, &variant, sizeof(QVariant));
QCOMPARE(buffer[0].type(), QVariant::UserType);
+ QCOMPARE(buffer[0].userType(), qMetaTypeId<MyNotMovable>());
MyNotMovable tmp(buffer[0].value<MyNotMovable>());
new (&variant) QVariant();
else if (id == QVariant::ByteArray)
return compare(v1.toByteArray(), v2.toByteArray());
- else if (id < int(QVariant::UserType)) // yes, v1.type()
- // QVariant can compare
- return v1 == v2;
-
else if (id == QMetaType::UChar)
return qvariant_cast<uchar>(v1) == qvariant_cast<uchar>(v2);
else if (id == qMetaTypeId<MyStruct>()) // (is)
return qvariant_cast<MyStruct>(v1) == qvariant_cast<MyStruct>(v2);
+ else if (id < int(QVariant::UserType)) // yes, v1.type()
+ // QVariant can compare
+ return v1 == v2;
+
else {
qWarning() << "Please write a comparison case for type" << v1.typeName();
return false; // unknown type