Details
-
Bug
-
Resolution: Fixed
-
Not Evaluated
-
5.15.16
-
1ebee8980 (dev), 113ecff9f (6.7), de6b76229 (6.6)
Description
Qt user reported following:
"
I've been struggling trying to understand how is QPolygonF serialized. This is the snippet of my unit test
void checkPoly() { QPolygonF poly; poly.append(QPointF(1,2)); poly.append(QPointF(3,4)); QByteArray qtBuf; {//save the polygon to a bytearray QBuffer b; QDataStream strm(&b); b.open(QIODevice::WriteOnly); strm << poly; qtBuf = b.buffer(); } {//read the polygon from the bytearray QBuffer b; b.setData(qtBuf); QDataStream strm(&b); b.open(QIODevice::ReadOnly); strm >> poly; QCOMPARE(poly.size(), 2); } }
This fails in Qt 5.15.16 because when loading the polygon again from the binary buffer the new values don't replace the old ones, they are appended to the existing ones and the final size is 4 instead of 2. That's an unexpected behavior or at least the function is not properly documented. Changing the code to use QPolygon or QVector<QPointF> or QList<QPointF> creates a container of size 2 as I would expect.
"
https://doc.qt.io/qt-5/qpolygon.html#operator-gt-gt
Mentions that:
"Reads a polygon from the given stream into the given polygon"
Attachments
Issue Links
- relates to
-
QTBUG-122704 QPainterPath de-serialisation from QDataStream fails if item isn't empty
- Closed