summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Köhne <kai.koehne@qt.io>2022-01-04 14:52:03 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-01-05 16:15:47 +0000
commitfdcc823d28ae6306f75b705514b0e7ff0e97e223 (patch)
treef98392f224fa15c2a352889a6a5b7bee1fcfd7b3
parentfa988a8cba3c43515b80be3081531c2b698f828c (diff)
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 <marc.mutz@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit a9084297f629423c64d571d7f7286d3c0e239247) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/shared/qtgradienteditor/qtgradientstopsmodel.cpp9
1 files 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 <typename BidirectionalIterator>
- std::reverse_iterator<BidirectionalIterator> rev(BidirectionalIterator it)
- { return std::reverse_iterator<BidirectionalIterator>(it); }
-}
-
void QtGradientStopsModel::flipAll()
{
QMap<qreal, QtGradientStop *> stopsMap = stops();
QMap<QtGradientStop *, bool> 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;