QPolygonF: delegate QDataStream marshalling to QList
Like the QPolygon code. This fixes a mistake in failing to clear the list before de-marshalling in operator>>. Updated most of the QDataStream tests to have data in the objects they're streaming into, to ensure that the stream overwrites everything. Fixes: QTBUG-122684 Task-number: QTBUG-122704 Pick-to: 6.6 6.5 5.15 Change-Id: I01ec3c774d9943adb903fffd17b6920c72f5042b Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 1ebee8980ba31514079a01989168914bfd1e9f4f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
59072e9916
commit
113ecff9f2
@ -697,13 +697,7 @@ QDataStream &operator>>(QDataStream &s, QPolygon &a)
|
|||||||
|
|
||||||
QDataStream &operator<<(QDataStream &s, const QPolygonF &a)
|
QDataStream &operator<<(QDataStream &s, const QPolygonF &a)
|
||||||
{
|
{
|
||||||
quint32 len = a.size();
|
return s << static_cast<const QList<QPointF> &>(a);
|
||||||
uint i;
|
|
||||||
|
|
||||||
s << len;
|
|
||||||
for (i = 0; i < len; ++i)
|
|
||||||
s << a.at(i);
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -718,17 +712,7 @@ QDataStream &operator<<(QDataStream &s, const QPolygonF &a)
|
|||||||
|
|
||||||
QDataStream &operator>>(QDataStream &s, QPolygonF &a)
|
QDataStream &operator>>(QDataStream &s, QPolygonF &a)
|
||||||
{
|
{
|
||||||
quint32 len;
|
return s >> static_cast<QList<QPointF> &>(a);
|
||||||
uint i;
|
|
||||||
|
|
||||||
s >> len;
|
|
||||||
a.reserve(a.size() + (int)len);
|
|
||||||
QPointF p;
|
|
||||||
for (i = 0; i < len; ++i) {
|
|
||||||
s >> p;
|
|
||||||
a.insert(i, p);
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
#endif //QT_NO_DATASTREAM
|
#endif //QT_NO_DATASTREAM
|
||||||
|
|
||||||
|
@ -2860,7 +2860,7 @@ QT_WARNING_POP
|
|||||||
#endif // QT_DEPRECATED_SINCE(6, 11)
|
#endif // QT_DEPRECATED_SINCE(6, 11)
|
||||||
{
|
{
|
||||||
QDataStream stream(&data, QIODevice::ReadOnly);
|
QDataStream stream(&data, QIODevice::ReadOnly);
|
||||||
QByteArray buf;
|
QByteArray buf = "Content to be overwritten";
|
||||||
stream >> buf;
|
stream >> buf;
|
||||||
|
|
||||||
if (data.startsWith("\xff\xff\xff\xff")) {
|
if (data.startsWith("\xff\xff\xff\xff")) {
|
||||||
@ -2952,7 +2952,7 @@ void tst_QDataStream::status_QString()
|
|||||||
QFETCH(QString, expectedString);
|
QFETCH(QString, expectedString);
|
||||||
|
|
||||||
QDataStream stream(&data, QIODevice::ReadOnly);
|
QDataStream stream(&data, QIODevice::ReadOnly);
|
||||||
QString str;
|
QString str = "Content to be overwritten";
|
||||||
stream >> str;
|
stream >> str;
|
||||||
|
|
||||||
QCOMPARE(str.size(), expectedString.size());
|
QCOMPARE(str.size(), expectedString.size());
|
||||||
@ -3047,7 +3047,7 @@ void tst_QDataStream::status_QBitArray()
|
|||||||
|
|
||||||
QDataStream stream(&data, QIODevice::ReadOnly);
|
QDataStream stream(&data, QIODevice::ReadOnly);
|
||||||
stream.setVersion(version);
|
stream.setVersion(version);
|
||||||
QBitArray str;
|
QBitArray str(255, true);
|
||||||
stream >> str;
|
stream >> str;
|
||||||
|
|
||||||
if (sizeof(qsizetype) == sizeof(int))
|
if (sizeof(qsizetype) == sizeof(int))
|
||||||
@ -3114,7 +3114,9 @@ void tst_QDataStream::status_QHash_QMap()
|
|||||||
hash2.insert("L", "MN");
|
hash2.insert("L", "MN");
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
|
hash = hash2;
|
||||||
MAP_TEST(QByteArray("\x00\x00\x00\x00", 4), QDataStream::Ok, QDataStream::Ok, StringHash());
|
MAP_TEST(QByteArray("\x00\x00\x00\x00", 4), QDataStream::Ok, QDataStream::Ok, StringHash());
|
||||||
|
hash = hash2;
|
||||||
MAP_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00", 12), QDataStream::Ok, QDataStream::Ok, hash1);
|
MAP_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00", 12), QDataStream::Ok, QDataStream::Ok, hash1);
|
||||||
MAP_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x02\x00J\x00\x00\x00\x02\x00K"
|
MAP_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x02\x00J\x00\x00\x00\x02\x00K"
|
||||||
"\x00\x00\x00\x02\x00L\x00\x00\x00\x04\x00M\x00N", 30), QDataStream::Ok, QDataStream::Ok, hash2);
|
"\x00\x00\x00\x02\x00L\x00\x00\x00\x04\x00M\x00N", 30), QDataStream::Ok, QDataStream::Ok, hash2);
|
||||||
@ -3195,7 +3197,9 @@ void tst_QDataStream::status_QList_QVector()
|
|||||||
someList.append("J");
|
someList.append("J");
|
||||||
someList.append("MN");
|
someList.append("MN");
|
||||||
|
|
||||||
|
list = someList;
|
||||||
LIST_TEST(QByteArray("\x00\x00\x00\x00", 4), QDataStream::Ok, QDataStream::Ok, List());
|
LIST_TEST(QByteArray("\x00\x00\x00\x00", 4), QDataStream::Ok, QDataStream::Ok, List());
|
||||||
|
list = someList;
|
||||||
LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x00", 8), QDataStream::Ok, QDataStream::Ok, listWithEmptyString);
|
LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x00", 8), QDataStream::Ok, QDataStream::Ok, listWithEmptyString);
|
||||||
LIST_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x02\x00J"
|
LIST_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x02\x00J"
|
||||||
"\x00\x00\x00\x04\x00M\x00N", 18), QDataStream::Ok, QDataStream::Ok, someList);
|
"\x00\x00\x00\x04\x00M\x00N", 18), QDataStream::Ok, QDataStream::Ok, someList);
|
||||||
@ -3263,6 +3267,13 @@ void tst_QDataStream::streamRealDataTypes()
|
|||||||
path.arcTo(4, 5, 6, 7, 8, 9);
|
path.arcTo(4, 5, 6, 7, 8, 9);
|
||||||
path.quadTo(1, 2, 3, 4);
|
path.quadTo(1, 2, 3, 4);
|
||||||
|
|
||||||
|
QPainterPath otherPath;
|
||||||
|
otherPath.arcTo(10, 4, 5, 6, 7, 8);
|
||||||
|
otherPath.lineTo(9, 0);
|
||||||
|
otherPath.cubicTo(0, 0, 10, 10, 20, 20);
|
||||||
|
otherPath.quadTo(2, 4, 5, 6);
|
||||||
|
QCOMPARE(otherPath.elementCount(), 12);
|
||||||
|
|
||||||
QColor color(64, 64, 64);
|
QColor color(64, 64, 64);
|
||||||
color.setAlphaF(0.5);
|
color.setAlphaF(0.5);
|
||||||
QRadialGradient radialGradient(5, 6, 7, 8, 9);
|
QRadialGradient radialGradient(5, 6, 7, 8, 9);
|
||||||
@ -3294,17 +3305,17 @@ void tst_QDataStream::streamRealDataTypes()
|
|||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF point;
|
QPointF point(1, 2);
|
||||||
QRectF rect;
|
QRectF rect(1, 2, 5, 6);
|
||||||
QPolygonF polygon;
|
QPolygonF polygon {{3, 4}, {5, 6}};
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
QPainterPath p;
|
QPainterPath p = otherPath;
|
||||||
QPicture pict;
|
QPicture pict;
|
||||||
QTextLength textLength;
|
QTextLength textLength(QTextLength::FixedLength, 2.5);
|
||||||
QColor col;
|
QColor col(128, 128, 127);
|
||||||
QBrush rGrad;
|
QBrush rGrad(Qt::CrossPattern);
|
||||||
QBrush cGrad;
|
QBrush cGrad(Qt::CrossPattern);
|
||||||
QPen pen;
|
QPen pen(conicalBrush, 10);
|
||||||
|
|
||||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
QDataStream stream(&file);
|
QDataStream stream(&file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user