mudlet-makers team mailing list archive
-
mudlet-makers team
-
Mailing list archive
-
Message #04034
[Bug 1471508] Re: No Qt QDatastream version control handling
Update: Creating a map file using a Mudlet 2.1 windows binary
download/install (which will be using Qt4.x series static libs) which
means it is using QDataStream::Qt_4_6 or equivalent DOES LOAD correctly
with a Mudlet version 3.0.0 preview compiled on Linux which is using a
later serialization format (QDataStream::Qt_5_4). IT turns out that on
Qt Desktop platforms since Qt4.6 although the type has changed from
"double" to "float" in the above listed types ALL floating point numbers
(both double AND float, and whichever qreal is using - the change in
which is what CAUSED all this kurfuffle) are saved/loaded with a
precision specified NOT by their declared type (float/double) but by
which value of the enum QDataStream::FloatingPointPrecision is currently
set for that QDataStream:
>From the Qt documentation:
"enum QDataStream::FloatingPointPrecision
The precision of floating point numbers used for reading/writing the data. This will only have an effect if the version of the data stream is Qt_4_6 or higher.
Warning: The floating point precision must be set to the same value on
the object that writes and the object that reads the data stream.
Constant Value Description
QDataStream::SinglePrecision 0 All floating point numbers in the data stream have 32-bit precision.
QDataStream::DoublePrecision 1 All floating point numbers in the data stream have 64-bit precision.
See also setFloatingPointPrecision() and floatingPointPrecision()."
The default value is Double Precision.
tl;dr;
We have not broken compatibility at least as far back as Mudlet 2.1 by NOT taking care to monitor the QDataStream file serialisation version but there is no guarantee that it will remain unchanged for Qt Classes that we read/write directly to a file. By explicitly specifying something now we can protect current user data files from becoming incompatible in the future.
--
You received this bug notification because you are a member of Mudlet
Makers, which is subscribed to Mudlet.
https://bugs.launchpad.net/bugs/1471508
Title:
No Qt QDatastream version control handling
Status in Mudlet the MUD client:
New
Bug description:
In https://bugs.launchpad.net/mudlet/+bug/1471406 several issues were
mentioned, this is one specific issue:
The Qt documents note:
"
QDataStream's binary format has evolved since Qt 1.0, and is likely to continue evolving to reflect changes done in Qt. When inputting or outputting complex types, it's very important to make sure that the same version of the stream (version()) is used for reading and writing. If you need both forward and backward compatibility, you can hardcode the version number in the application:
stream.setVersion(QDataStream::Qt_4_0);
"
We do not currently do this, so, theoretically if someone tries to
load a map file format version 4 (the earliest that we still support)
there is no guarantee that the current Qt libraries will parse the
serialized bytes in the same manner as they did in the past - however
by addressing that, this become an issue that we can solve for the
future.
I would suggest that for the moment we use Qt_4_6 WHEN WRITING as I
think that will be compatible with what was used when the binaries for
Mudlet 2.1 were created.
I have checked the differences between Qt_4_8 (which is THE SAME as
Qt_4_6, QDataStream enum value 12) and the current (Qt_5_4 enum value
16) and the differences are:
QDateTime:
Date (QDate)
Time (QTime)
0 for Qt::LocalTime,
1 for Qt::UTC (quint8)
*** ONLY IN Qt_5_4 ***
2 for Qt::OffsetFromUTC = An offset in seconds from Coordinated Universal Time.
3 for Qt::TimeZone = A named time zone using a specific set of Daylight Savings rules.
**********************
*** Only in Qt_5_4
QMargins:
left (int)
top (int)
right (int)
bottom (int)
QRegularExpression:
The regular expression pattern (QString)
The pattern options (quint32)
***
In addition in:
QMatrix4x4
QQuaternion
QVector2D
QVector3D
QVector4D
*** In Qt_5_4 ***
All the above have several elements that are ALL floats NOT doubles
***
The only ones that could be relevant to us here is QDateTime but we do
not (currently) save such a value in any of the different files AFAICT
and QVector3D (which is unused) in two places in TArea as span and
pos, I'm not totally clear on the number of bytes used for a float and
how that compares to a double (more for the latter) so that ought to
mean we should be having problems but it is not clear that we are -
I'll try to download a windows binary version of 2.1 and see what
happens if I create a map with that and then load it into a current
Mudlet version compiled with Qt5.4...
UPDATE TO FOLLOW...(I need some sleep)
To manage notifications about this bug go to:
https://bugs.launchpad.net/mudlet/+bug/1471508/+subscriptions
References