diff options
author | Kai Köhne <kai.koehne@qt.io> | 2022-01-04 14:52:03 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-05 17:15:47 +0000 |
commit | 6a05c1ac8b73bc009da6cef62eb1ff180811f5f7 (patch) | |
tree | 0c716e20e5887482074e494883a0f7dca8496698 | |
parent | 2a46b6d4eff743d11cba991a381736a9a159e786 (diff) | |
download | qttools-6a05c1ac8b73bc009da6cef62eb1ff180811f5f7.tar.gz |
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.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp b/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp index cd587793e..c064eeff4 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; |