From f2aaf5f3b528f954c4ff7b3e6a79acae157cec5e Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Mon, 11 Sep 2017 13:14:28 +0300 Subject: Select min of m_points and points On QXYSeriesPrivate::drawSeriesPointLabels the loop is based on m_points.size(), but points vector may have less items because of animation. This patch takes the min of vectors. Task-number: QTBUG-63123 Change-Id: I940fd5557abd3a28d064ab2c2737fae650fd7183 Reviewed-by: Miikka Heikkinen --- src/charts/xychart/qxyseries.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/charts/xychart/qxyseries.cpp b/src/charts/xychart/qxyseries.cpp index 40382d15..c85d5340 100644 --- a/src/charts/xychart/qxyseries.cpp +++ b/src/charts/xychart/qxyseries.cpp @@ -1001,6 +1001,9 @@ void QXYSeriesPrivate::initializeAnimations(QtCharts::QChart::AnimationOptions o void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVector &points, const int offset) { + if (points.size() == 0) + return; + static const QString xPointTag(QLatin1String("@xPoint")); static const QString yPointTag(QLatin1String("@yPoint")); const int labelOffset = offset + 2; @@ -1010,7 +1013,8 @@ void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVectorfont()); // m_points is used for the label here as it has the series point information // points variable passed is used for positioning because it has the coordinates - for (int i(0); i < m_points.size(); i++) { + const int pointCount = qMin(points.size(), m_points.size()); + for (int i(0); i < pointCount; i++) { QString pointLabel = m_pointLabelsFormat; pointLabel.replace(xPointTag, presenter()->numberToString(m_points.at(i).x())); pointLabel.replace(yPointTag, presenter()->numberToString(m_points.at(i).y())); -- cgit v1.2.3