summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTamas Martinec <tamas.martinec@symbio.com>2021-01-15 11:00:22 +0200
committerTamas Martinec <tamas.martinec@symbio.com>2021-01-15 11:51:45 +0200
commit8fbbe10910c1eb2fece94e065c81f6b94c35f02a (patch)
tree1f43173e19251606c1e6c9127ca205a67d1001ac /src
parent130463160b4923069eb98da49edaf7d93180f4f8 (diff)
QtCharts: Append branch condition fix in QLegend
Qlist insert was called with -1 as position in QLegendPrivate::handleCountChanged, as pos = indexOfSeries(series, m_markers) is used as insert pos, which has -1 if the series is not found in the markers. The branch condition that should handle this use case was mistaken and the else branch executed which was not inteded. The else branch was still functional since the insert position protection adjusted it to 0 but it gave an assert because of the -1 as insert position. The assert and warning for negative indices was added in 5.15, which is why there was no warning before. Corrected the condition. The issue doesn't look platform dependent. Fixes: QTBUG-85909 Change-Id: I78c7dba3b4793ad23f1508c11bd43bca8b4533ed Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/charts/legend/qlegend.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/charts/legend/qlegend.cpp b/src/charts/legend/qlegend.cpp
index 6f5c2bb1..1a4f0ea2 100644
--- a/src/charts/legend/qlegend.cpp
+++ b/src/charts/legend/qlegend.cpp
@@ -772,7 +772,7 @@ void QLegendPrivate::handleCountChanged()
}
// Re-insert createdMarkers into m_markers in correct order.
- if (pos != -1 || pos == m_markers.size()) {
+ if (pos == -1 || pos == m_markers.size()) {
m_markers.append(createdMarkers);
} else {
for (int c = createdMarkers.size() - 1; c >= 0; --c)