summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-07-30 22:42:31 +0200
committerLars Knoll <lars.knoll@qt.io>2020-08-24 00:17:03 +0200
commited8acbeb7c6fd137486b5c8a6eec58a3b9db862c (patch)
treed92c3f06a07082e2cc40be366faac8bc58b82def /tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
parent5282545589244c1a3e01442e3586d5666213f76d (diff)
Automatically register data/debug stream operations in QMetaType
And remove the old manual registration code for those operators. Add some special handling for long/ulong, as these types could be streamed as a QVariant so far, but are not directly streamable through QDataStream. [ChangeLog][QtCore][QMetaType] The QMetaType::registerStreamOperators() and QMetaType::registerDebugStreamOperator() methods have been removed. The streaming operators for a type are now automatically registered together with the type registration. This implies that the operators should be visible wherever the type is visible and being used. [ChangeLog][Behavior Incompatible Changes] Because the QDataStream and QDebug serialization operators are automatically registered with QMetaType, the declarations of those functions must be present at any point where the type is used with QMetaType and QVariant. Change-Id: I4a0732651b20319af4a8397ff90b848ca4580d99 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp')
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp8
1 files changed, 1 insertions, 7 deletions
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index aeac08fc34..02a537a9d6 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -1222,7 +1222,6 @@ struct CustomStreamableClass
return i == other.i;
}
};
-Q_DECLARE_METATYPE(CustomStreamableClass);
QDataStream &operator<<(QDataStream &out, const CustomStreamableClass &myObj)
{
@@ -1233,11 +1232,10 @@ QDataStream &operator>>(QDataStream &in, CustomStreamableClass &myObj)
{
return in >> myObj.i;
}
+Q_DECLARE_METATYPE(CustomStreamableClass);
void tst_QVariant::writeToReadFromDataStream_data()
{
- qRegisterMetaTypeStreamOperators<CustomStreamableClass>();
-
QTest::addColumn<QVariant>("writeVariant");
QTest::addColumn<bool>("isNull");
{
@@ -2184,8 +2182,6 @@ void tst_QVariant::saveLoadCustomTypes()
auto tp = QMetaType::fromType<Blah>();
QVariant v = QVariant(tp, &i);
- qRegisterMetaTypeStreamOperators<Blah>("Blah");
-
QCOMPARE(v.userType(), tp.id());
QCOMPARE(v.type(), QVariant::UserType);
{
@@ -4639,8 +4635,6 @@ void tst_QVariant::fromStdVariant()
void tst_QVariant::qt4UuidDataStream()
{
- qRegisterMetaTypeStreamOperators<QUuid>();
-
QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly);
stream.setVersion(QDataStream::Qt_4_8);