diff options
author | Mika Salmela <mika.salmela@qt.io> | 2017-09-11 13:14:28 +0300 |
---|---|---|
committer | Mika Salmela <mika.salmela@qt.io> | 2017-09-12 09:08:19 +0000 |
commit | f2aaf5f3b528f954c4ff7b3e6a79acae157cec5e (patch) | |
tree | 3266c2b8605567a7535e33eb0dd205f7bc6d6464 | |
parent | 524229e31d7f8141c3f91cdad2cffa36131d6789 (diff) |
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 <miikka.heikkinen@qt.io>
-rw-r--r-- | src/charts/xychart/qxyseries.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
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<QPointF> &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 QVector<QP QFontMetrics fm(painter->font()); // 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())); |