summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/positioning/qgeopath.cpp11
-rw-r--r--src/positioning/qgeopolygon.cpp25
2 files changed, 30 insertions, 6 deletions
diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp
index aeec2315..88e4d5a4 100644
--- a/src/positioning/qgeopath.cpp
+++ b/src/positioning/qgeopath.cpp
@@ -50,6 +50,10 @@
#include "qdoublevector3d_p.h"
QT_BEGIN_NAMESPACE
+constexpr int kMaxInt = std::numeric_limits<int>::max();
+constexpr auto kWarningString = u"The path has more elements than fit into an int. "
+ "This can cause errors while querying elements from QML";
+
/*!
\class QGeoPath
\inmodule QtPositioning
@@ -311,7 +315,10 @@ double QGeoPath::length(qsizetype indexFrom, qsizetype indexTo) const
qsizetype QGeoPath::size() const
{
Q_D(const QGeoPath);
- return d->size();
+ const qsizetype result = d->size();
+ if (result > kMaxInt)
+ qWarning() << kWarningString;
+ return result;
}
/*!
@@ -321,6 +328,8 @@ void QGeoPath::addCoordinate(const QGeoCoordinate &coordinate)
{
Q_D(QGeoPath);
d->addCoordinate(coordinate);
+ if (d->size() > kMaxInt)
+ qWarning() << kWarningString;
}
/*!
diff --git a/src/positioning/qgeopolygon.cpp b/src/positioning/qgeopolygon.cpp
index cba8b7b5..c34f3631 100644
--- a/src/positioning/qgeopolygon.cpp
+++ b/src/positioning/qgeopolygon.cpp
@@ -53,6 +53,12 @@
QT_BEGIN_NAMESPACE
+constexpr int kMaxInt = std::numeric_limits<int>::max();
+constexpr auto kTooManyHoles = u"The polygon has more holes than fit into an int. "
+ "This can cause errors while querying holes from QML";
+constexpr auto kTooManyElements = u"The polygon has more elements than fit into an int. "
+ "This can cause errors while querying elements from QML";
+
/*!
\class QGeoPolygon
\inmodule QtPositioning
@@ -298,7 +304,10 @@ double QGeoPolygon::length(qsizetype indexFrom, qsizetype indexTo) const
qsizetype QGeoPolygon::size() const
{
Q_D(const QGeoPolygon);
- return d->size();
+ const qsizetype result = d->size();
+ if (result > kMaxInt)
+ qWarning() << kTooManyElements;
+ return result;
}
/*!
@@ -308,6 +317,8 @@ void QGeoPolygon::addCoordinate(const QGeoCoordinate &coordinate)
{
Q_D(QGeoPolygon);
d->addCoordinate(coordinate);
+ if (d->size() > kMaxInt)
+ qWarning() << kTooManyElements;
}
/*!
@@ -389,7 +400,6 @@ QString QGeoPolygon::toString() const
*/
void QGeoPolygon::addHole(const QVariant &holePath)
{
- Q_D(QGeoPolygon);
QList<QGeoCoordinate> qgcHolePath;
if (holePath.canConvert<QVariantList>()) {
const QVariantList qvlHolePath = holePath.toList();
@@ -399,7 +409,7 @@ void QGeoPolygon::addHole(const QVariant &holePath)
}
}
//ToDo: add QGeoShape support
- return d->addHole(qgcHolePath);
+ addHole(qgcHolePath);
}
/*!
@@ -410,7 +420,9 @@ void QGeoPolygon::addHole(const QVariant &holePath)
void QGeoPolygon::addHole(const QList<QGeoCoordinate> &holePath)
{
Q_D(QGeoPolygon);
- return d->addHole(holePath);
+ d->addHole(holePath);
+ if (d->holesCount() > kMaxInt)
+ qDebug() << kTooManyHoles;
}
/*!
@@ -458,7 +470,10 @@ void QGeoPolygon::removeHole(qsizetype index)
qsizetype QGeoPolygon::holesCount() const
{
Q_D(const QGeoPolygon);
- return d->holesCount();
+ const qsizetype result = d->holesCount();
+ if (result > kMaxInt)
+ qWarning() << kTooManyHoles;
+ return result;
}
/*******************************************************************************