From fdcc823d28ae6306f75b705514b0e7ff0e97e223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20K=C3=B6hne?= Date: Tue, 4 Jan 2022 14:52:03 +0100 Subject: designer: Fix MSVC warning about returning address of local variable or temporary std::reverse_iterator::operator*() returns by reference while QKeyValueIterator::operator*() returns by value, so MSVC is correct when it warns about returning the address of a local variable or temporary in (*itStop).second: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.30.30705\include\xutility(1582) : error C2220: the following warning is treated as an error C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.30.30705\include\xutility(1582) : warning C4172: returning address of local variable or temporary Avoid this by just iterating backwards. Amends 6ed8a22dd2756557954dc85052870c0894de06ba. Change-Id: I01ce7cb151efa61e8702686b3a463790869df72c Reviewed-by: Marc Mutz Reviewed-by: Giuseppe D'Angelo (cherry picked from commit a9084297f629423c64d571d7f7286d3c0e239247) Reviewed-by: Qt Cherry-pick Bot --- src/shared/qtgradienteditor/qtgradientstopsmodel.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp b/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp index 0afbf49bb..2422926c4 100644 --- a/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp +++ b/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp @@ -418,17 +418,12 @@ void QtGradientStopsModel::clearSelection() selectStop(stop, false); } -namespace { - template - std::reverse_iterator rev(BidirectionalIterator it) - { return std::reverse_iterator(it); } -} - void QtGradientStopsModel::flipAll() { QMap stopsMap = stops(); QMap swappedList; - for (auto itStop = rev(stopsMap.keyValueEnd()), end = rev(stopsMap.keyValueBegin()); itStop != end; ++itStop) { + for (auto itStop = stopsMap.keyValueEnd(), begin = stopsMap.keyValueBegin(); itStop != begin;) { + --itStop; QtGradientStop *stop = (*itStop).second; if (swappedList.contains(stop)) continue; -- cgit v1.2.3