Don't crash if QQuickPath has less than 4 elements
authorShawn Rutledge <shawn.rutledge@digia.com>
Mon, 29 Apr 2013 11:51:15 +0000 (13:51 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 30 Apr 2013 06:01:16 +0000 (08:01 +0200)
When running the Qt Cinematic demo on Android, the assertion
ASSERT: "i >= 0 && i < elementCount()" in painting/qpainterpath.cpp
failed because of a zero default size at startup.

Change-Id: I2c46c43319cf71030cf03b1f7c6cdaec782ce11a
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
src/quick/util/qquickpath.cpp

index fc33f8f..2278fd2 100644 (file)
@@ -1546,7 +1546,7 @@ void QQuickPathCatmullRomCurve::addToPath(QPainterPath &path, const QQuickPathDa
         nextData.curves = data.curves;
         next = positionForCurve(nextData, point);
     } else {
-        if (point == QPointF(path.elementAt(0)) && qobject_cast<QQuickPathCatmullRomCurve*>(data.curves.at(0))) {
+        if (point == QPointF(path.elementAt(0)) && qobject_cast<QQuickPathCatmullRomCurve*>(data.curves.at(0)) && path.elementCount() >= 3) {
             //this is a closed path starting and ending with catmull-rom segments.
             //we try to smooth the join point
             next = QPointF(path.elementAt(3));  //the first catmull-rom point