diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-01-11 06:48:31 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-01-19 19:18:25 -0800 |
commit | 7ced4f03281c253be098c126b72457201a44d2a0 (patch) | |
tree | 694bc22e2600d54e9562cdbd0e1becf91dc4b76c /src/charts/axis/chartaxiselement.cpp | |
parent | 12c4f30152ddf3bccb4c26e5e8b2cb0aa1774aa7 (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.cpp | 2 |
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); } } |