mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 08:38:45 +00:00
Fix float parsing bug that manifests on Qt4.6 and later.
This file relies on Qt's QDataStream to handle the parsing of primitive C types from Computrainer .3dp files, including floats. In Qt4.5 and earlier, Qt defaulted to 32 bit floats. In Qt4.6 and later, Qt started using 64 bit floats by default. As a side-effect, parsing broke on Qt4.6, leading to a crash when importing or using .3dp files. This patch fixes the issue by using QDataStream's "setVersion()" method to tell Qt to use the Qt4.0 serialization format for the QDataStream used in this file. This patch does not affect any other files. This patch should make the formatting assumptions both backwards and forwards compatible.
This commit is contained in:
@@ -60,6 +60,12 @@ RideFile *Computrainer3dpFileReader::openRideFile(QFile & file,
|
||||
}
|
||||
RideFile *rideFile = new RideFile();
|
||||
QDataStream is(&file);
|
||||
|
||||
// Note that QT4.6 and above default to 64 bit floats. For
|
||||
// backwards and forwards compatibility, we'll freeze the stream
|
||||
// version we use for parsing at 4.0, and then add in LittleEndian
|
||||
// number format, which is what Computrainer3dp has.
|
||||
is.setVersion(QDataStream::Qt_4_0);
|
||||
is.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
// start parsing the header
|
||||
|
||||
Reference in New Issue
Block a user