ensure the type name is streamed as QByteArray in QVariant::save()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-11-03 16:36:28 +02:00
parent 7f04979b7e
commit 35f05e0d94
2 changed files with 5 additions and 1 deletions

View file

@ -107,6 +107,10 @@ public:
int skipRawData(int len); int skipRawData(int len);
private: private:
// ASCII is ambiguous, write either QString or QByteArray
QDataStream &operator<<(const char *str);
QDataStream &operator>>(char *&str);
Q_DISABLE_COPY(QDataStream) Q_DISABLE_COPY(QDataStream)
QIODevice *dev; QIODevice *dev;

View file

@ -1687,7 +1687,7 @@ void QVariant::save(QDataStream &s) const
s << tp; s << tp;
s << qint8(d_ptr ? d_ptr->is_null : true); s << qint8(d_ptr ? d_ptr->is_null : true);
if (tp == QVariant::UserType) { if (tp == QVariant::UserType) {
s << QMetaType::typeName(userType()); s << QByteArray(QMetaType::typeName(userType()));
} }
if (!isValid()) { if (!isValid()) {