summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-01-11 06:48:31 -0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-01-20 05:26:24 +0000
commit59c1f47d9dc54caa29f8ad4ac2782784d4cb4ab7 (patch)
tree5957349cece5e96909530259afcdb2f5cc9bc8b0
parent68130974d52f8e654ee062f46faba554926057f5 (diff)
QtCharts: fix GCC 13-detected dangling element reference warning
QColorAxis::gradient() returns a QLinearGradient by value, QGradient::stops() returns a QList<QGradientStop> by value, so storing the reference returned by QList::operator[] is, strictly speaking, dangling. In practice, it isn't because QList is COW and thus the element is not going to be destroyed, but let's not depend on that detail. chartaxiselement.cpp:437:33: error: possibly dangling reference to a temporary [-Werror=dangling-reference] chartaxiselement.cpp:437:71: note: the temporary was destroyed at the end of the full expression ‘QGradient::stops() const().QList<std::pair<double, QColor> >::operator[](((qsizetype)i))’ Change-Id: Ide4dbd0777a44ed0870efffd1739488e1958f814 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> (cherry picked from commit 7ced4f03281c253be098c126b72457201a44d2a0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/charts/axis/chartaxiselement.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/charts/axis/chartaxiselement.cpp b/src/charts/axis/chartaxiselement.cpp
index 1723ba29..bfabfa26 100644
--- a/src/charts/axis/chartaxiselement.cpp
+++ b/src/charts/axis/chartaxiselement.cpp
@@ -434,7 +434,7 @@ void ChartAxisElement::prepareColorScale(const qreal width, const qreal height)
} else {
gradient = QLinearGradient(QPointF(0, 0), QPointF(0, height));
for (int i = colorAxis->gradient().stops().size() - 1; i >= 0; --i) {
- const auto &stop = colorAxis->gradient().stops()[i];
+ auto stop = colorAxis->gradient().stops()[i];
gradient.setColorAt(1 - stop.first, stop.second);
}
}