qt6-bb10/tests/auto/corelib/serialization
Thiago Macieira 46dc8e453a QVariant: use a typedef name when saving user types to QDataStream
Due to the way Qt 5 and 6 registered type names, they end up producing
different type names for the same content for a typedef. For example,
because Q_DECLARE_METATYPE can't manage a comma (it's a macro), users
are forced to write something like:

 using MyTypeMap = QMap<QString, MyType>
 Q_DECLARE_METATYPE(MyTypeMap)

Qt 5's Q_DECLARE_METATYPE's argument "MyTypeMap" was the only name we
knew about the type, so that's what got saved in the stream. However, Qt
6 QtPrivate::typenameHelper is much more clever and obtains the name
from the compiler itself, so it "sees through" the typedef and registers
"QMap<QString,MyType>" as the official type name.

If another library/plugin has a different typedef name for the same type
(e.g., StringTypeMap), it's indeterminate which type gets saved and will
even change from run to run (depends on the QHash order).

[ChangeLog][QtCore][QDataStream] If QDataStream is used with a
QDataStream::Version < Qt_6_0 to serialize a user type that was
registered via a typedef with the metatype system, the typedef's name is
used in the stream instead of the non-typedef name. This restores
compatibility with Qt 5, allowing existing content to read the same
QDataStreams; reading from older Qt 6 versions should not be affected.
(Note: if more than one typedef name is registered, it's indetermine
which name gets used)

Fixes: QTBUG-96916
Pick-to: 6.3 6.2
Change-Id: I2bbf422288924c198645fffd16a8d811aa58201e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-12-17 17:54:05 +01:00
..
json QNX: Remove expected fail 2021-12-12 13:11:52 +02:00
qcborstreamreader tests: Remove unused SRCDIR defines 2021-08-17 12:41:57 +00:00
qcborstreamwriter tests: Remove unused SRCDIR defines 2021-08-17 12:41:57 +00:00
qcborvalue tests: Remove unused SRCDIR defines 2021-08-17 12:41:57 +00:00
qcborvalue_json tests: Remove unused SRCDIR defines 2021-08-17 12:41:57 +00:00
qdatastream QVariant: use a typedef name when saving user types to QDataStream 2021-12-17 17:54:05 +01:00
qdatastream_core_pixmap Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtextstream Add missing dependencies of tests on their helper programs 2021-09-17 12:57:25 +02:00
qxmlstream Correct prefix reported for end element in QXmlStreamReader 2021-04-20 03:03:51 +02:00
CMakeLists.txt Android: exclude tests crashing at start 2020-11-16 13:35:44 +02:00
cborlargedatavalidation.cpp Replace QtTest headers with QTest 2020-12-22 15:20:30 +01:00