summaryrefslogtreecommitdiff
path: root/src/positioning/qgeoshape.cpp
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-07-15 17:13:33 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-07-19 08:11:40 +0000
commitb683cbe594791f886cdd8612e60be93b77282a4b (patch)
tree87e1acf8b9369b2aa87e0267d5b1af1d073daf31 /src/positioning/qgeoshape.cpp
parentc5738389abfbd07df03c37be5ec8e1d8bcdb66ac (diff)
downloadqtlocation-b683cbe594791f886cdd8612e60be93b77282a4b.tar.gz
QGeoShape: fix serialization of QGeoPolygon and QGeoPath
There were two problems: 1. The deserialization method was still assuming that QList uses int to index the elements, so it tried to extract the polygon and path size as int, while it was serialized as qsizetype. 2. The QGeoPath didn't serialize and deserialize its width - it was simply lost. This patch fixes both problems and adds some unit-tests to cover these cases. Change-Id: If0ac87731b4481fde6b91e71fb121b3e916b0bfe Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit b7fa0a29ff70dd3316941cf9ec9936d7c1a8434c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/positioning/qgeoshape.cpp')
-rw-r--r--src/positioning/qgeoshape.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/positioning/qgeoshape.cpp b/src/positioning/qgeoshape.cpp
index 859df96e..d4daf813 100644
--- a/src/positioning/qgeoshape.cpp
+++ b/src/positioning/qgeoshape.cpp
@@ -357,6 +357,7 @@ QDataStream &operator<<(QDataStream &stream, const QGeoShape &shape)
}
case QGeoShape::PathType: {
QGeoPath p = shape;
+ stream << p.width();
stream << p.path().size();
for (const auto &c: p.path())
stream << c;
@@ -400,21 +401,23 @@ QDataStream &operator>>(QDataStream &stream, QGeoShape &shape)
case QGeoShape::PathType: {
QList<QGeoCoordinate> l;
QGeoCoordinate c;
- int sz;
+ qreal width;
+ stream >> width;
+ qsizetype sz;
stream >> sz;
- for (int i = 0; i < sz; i++) {
+ for (qsizetype i = 0; i < sz; i++) {
stream >> c;
l.append(c);
}
- shape = QGeoPath(l);
+ shape = QGeoPath(l, width);
break;
}
case QGeoShape::PolygonType: {
QList<QGeoCoordinate> l;
QGeoCoordinate c;
- int sz;
+ qsizetype sz;
stream >> sz;
- for (int i = 0; i < sz; i++) {
+ for (qsizetype i = 0; i < sz; i++) {
stream >> c;
l.append(c);
}