diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-04-23 17:39:08 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-04-24 10:22:35 +0300 |
commit | c4f9629c130d507c9536d93467ee76eb5fa30539 (patch) | |
tree | 3602fa3f494a38166e64e1bee9568a49ad54fe3c /src/splinechart/splinechartitem.cpp | |
parent | 5862599d088d072b4ac89ed556a645680f786d80 (diff) |
Fix crash when adding/removing points during animation
Adding/removing points during the animation of the previous
add/remove operation resulted in a mismatch between visible
point count and the actual point count, leading to crashes
in code that assumed both to be the same. Added necessary
safeguards and improved autotests to detect these cases.
Task-number: QTRD-1984
Change-Id: I544d10a69e760a40d4c90a4f02de61d4d1bb974f
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/splinechart/splinechartitem.cpp')
-rw-r--r-- | src/splinechart/splinechartitem.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/splinechart/splinechartitem.cpp b/src/splinechart/splinechartitem.cpp index 4a46a724..4f1162c1 100644 --- a/src/splinechart/splinechartitem.cpp +++ b/src/splinechart/splinechartitem.cpp @@ -141,6 +141,9 @@ void SplineChartItem::updateGeometry() qreal rightMarginLine = centerPoint.x() + margin; qreal horizontal = centerPoint.y(); + // See ScatterChartItem::updateGeometry() for explanation why seriesLastIndex is needed + const int seriesLastIndex = m_series->count() - 1; + for (int i = 1; i < points.size(); i++) { // Interpolating spline fragments accurately is not trivial, and would anyway be ugly // when thick pen is used, so we work around it by utilizing three separate @@ -154,7 +157,7 @@ void SplineChartItem::updateGeometry() // degrees and both of the points are within the margin, one in the top half and one in the // bottom half of the chart, the bottom one gets clipped incorrectly. // However, this should be rare occurrence in any sensible chart. - currentSeriesPoint = m_series->pointAt(i); + currentSeriesPoint = m_series->pointAt(qMin(seriesLastIndex, i)); currentGeometryPoint = points.at(i); pointOffGrid = (currentSeriesPoint.x() < minX || currentSeriesPoint.x() > maxX); |