Skip to content

Commit a791032

Browse files
marcmutzQt Cherry-pick Bot
authored andcommitted
QLocale/Win: don't move from an lvalue
The nullIfEmpty() function took its argument by universal reference, but then unconditionally moved from it into a QVariant. As long as QVariant didn't have ctors from rvalue-refs, this wasn't an actual move, but still a copy (std::move() doesn't move, it's an lvalue-to-rvalue (xvalue) cast). With the implementation of move-ctors for QVariant (QTBUG-53265), this suddenly becomes a move and, in zeroDigit(), moves away from the 'zero' member. Issue location found by Copilot. Fix by forwarding from the universal reference instead of moving. Contrary to what Copilot keeps telling me, this _is_ the correct fix. Amends 385626d. Pick-to: 6.10 6.8 6.5 Change-Id: I91cba49f39506d403b3f7a21c9f4b58fd91af8d5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit ad0b53f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
1 parent aeb47c4 commit a791032

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/corelib/text/qlocale_win.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static QVariant nullIfEmpty(T &&value)
9999
// For use where we should fall back to CLDR if we got an empty value.
100100
if (value.isEmpty())
101101
return {};
102-
return std::move(value);
102+
return std::forward<T>(value);
103103
}
104104
}
105105

0 commit comments

Comments
 (0)