diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 232a134718..718c42ba55 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1255,7 +1255,6 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data) case QMetaType::UnknownType: case QMetaType::Void: case QMetaType::VoidStar: - case QMetaType::Nullptr: case QMetaType::QObjectStar: case QMetaType::QModelIndex: case QMetaType::QPersistentModelIndex: @@ -1264,6 +1263,8 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data) case QMetaType::QJsonArray: case QMetaType::QJsonDocument: return false; + case QMetaType::Nullptr: + return true; case QMetaType::Long: stream << qlonglong(*static_cast(data)); break; @@ -1477,7 +1478,6 @@ bool QMetaType::load(QDataStream &stream, int type, void *data) case QMetaType::UnknownType: case QMetaType::Void: case QMetaType::VoidStar: - case QMetaType::Nullptr: case QMetaType::QObjectStar: case QMetaType::QModelIndex: case QMetaType::QPersistentModelIndex: @@ -1486,6 +1486,8 @@ bool QMetaType::load(QDataStream &stream, int type, void *data) case QMetaType::QJsonArray: case QMetaType::QJsonDocument: return false; + case QMetaType::Nullptr: + return true; case QMetaType::Long: { qlonglong l; stream >> l; diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 7d9f56ef38..7e1979dfb3 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -1559,7 +1559,6 @@ DECLARE_NONSTREAMABLE(QJsonArray) DECLARE_NONSTREAMABLE(QJsonDocument) DECLARE_NONSTREAMABLE(QObject*) DECLARE_NONSTREAMABLE(QWidget*) -DECLARE_NONSTREAMABLE(std::nullptr_t) #define DECLARE_GUI_CLASS_NONSTREAMABLE(MetaTypeName, MetaTypeId, RealType) \ DECLARE_NONSTREAMABLE(RealType) @@ -1598,7 +1597,10 @@ void tst_QMetaType::saveAndLoadBuiltin() if (isStreamable) { QVERIFY(QMetaType::load(stream, type, value)); // Hmmm, shouldn't it return false? - QCOMPARE(stream.status(), QDataStream::ReadPastEnd); + + // std::nullptr_t is nullary: it doesn't actually read anything + if (type != QMetaType::Nullptr) + QCOMPARE(stream.status(), QDataStream::ReadPastEnd); } stream.device()->seek(0); @@ -1608,7 +1610,10 @@ void tst_QMetaType::saveAndLoadBuiltin() if (isStreamable) { QVERIFY(QMetaType::load(stream, type, value)); // Hmmm, shouldn't it return false? - QCOMPARE(stream.status(), QDataStream::ReadPastEnd); + + // std::nullptr_t is nullary: it doesn't actually read anything + if (type != QMetaType::Nullptr) + QCOMPARE(stream.status(), QDataStream::ReadPastEnd); } QMetaType::destroy(type, value);