[Qt-interest] Possible bug in QTextStream when used with QByteArray

Malyushytsky, Alex alex at wai.com
Wed Jul 7 00:52:38 CEST 2010


Just fixing incorrect problem description.
Code is the same as in the original message.

I have a problem which looks like a bug in QTextStream.

I need to compress some text file which has pairs of numbers except 3 top lines and write it to the file.
As a part of the process I need to be able to write/read data into/from QByteArray on per value basis.

An attempt to do it works for a while but fails at some point.
For the test data on the 14066 line value read is not equal to value written (it is correct until that point).

At this point when value is read an extra character which belongs to the next value is read as a part of current value.

// values written into QByteArray
// val =  0.275119
// val =  0.056078  ! this value is CORRECT
// val =  4.28628   ! this value is CORRECT

// values read from the QByteArray
// val =  0.275119
// val =  0.0560784 !!!!!!!!!!! expected 0.056078
// val =  0.28628  !!!!!!!!!!! expected  4.28628

Trying to localize problem allowed to come to conclusion that problem happens either:
 - when value is written to QByteArray using QTextStream out ( &_array, QIODevice::WriteOnly );
 - or when value is read from the same array using QTextStream in ( &_array, QIODevice::ReadOnly );

Any restriction on size of QByteArray I am missing?

QT 4.6.0 MSVC 2005, Windows XP 64 bit.


Regards,
   Alex


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”

“Please consider our environment before printing this email.”




More information about the Qt-interest-old mailing list