summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/positioning/qgeopath.cpp3
-rw-r--r--tests/auto/qgeopath/tst_qgeopath.cpp1
2 files changed, 4 insertions, 0 deletions
diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp
index 35d82b5f..beb43692 100644
--- a/src/positioning/qgeopath.cpp
+++ b/src/positioning/qgeopath.cpp
@@ -483,6 +483,9 @@ void QGeoPathPrivate::setWidth(const qreal &width)
double QGeoPathPrivate::length(int indexFrom, int indexTo) const
{
+ if (path().isEmpty())
+ return 0.0;
+
bool wrap = indexTo == -1;
if (indexTo < 0 || indexTo >= path().size())
indexTo = path().size() - 1;
diff --git a/tests/auto/qgeopath/tst_qgeopath.cpp b/tests/auto/qgeopath/tst_qgeopath.cpp
index 97bf69fe..213af0ad 100644
--- a/tests/auto/qgeopath/tst_qgeopath.cpp
+++ b/tests/auto/qgeopath/tst_qgeopath.cpp
@@ -70,6 +70,7 @@ void tst_QGeoPath::defaultConstructor()
QGeoPath p;
QVERIFY(!p.path().size());
QCOMPARE(p.width(), qreal(0.0));
+ QCOMPARE(p.length(), double(0.0));
}
void tst_QGeoPath::listConstructor()