summaryrefslogtreecommitdiffstats
path: root/src/charts/axis/chartaxiselement.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-01-11 06:48:31 -0800
committerThiago Macieira <thiago.macieira@intel.com>2023-01-19 19:18:25 -0800
commit7ced4f03281c253be098c126b72457201a44d2a0 (patch)
tree694bc22e2600d54e9562cdbd0e1becf91dc4b76c /src/charts/axis/chartaxiselement.cpp
parent12c4f30152ddf3bccb4c26e5e8b2cb0aa1774aa7 (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))’ Pick-to: 6.5 Change-Id: Ide4dbd0777a44ed0870efffd1739488e1958f814 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/charts/axis/chartaxiselement.cpp')
-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);
}
}