QStringConverter: Do not use std::optional::value()

value() can potentially throw an exception. We know that it doesn't in
this case, but the compiler doesn't know. And our code checker doesn't
know either and generates lots of false positives. Also, without the
exception propagation code the resulting binary is probably smaller.

Coverity-Id: 386110
Coverity-Id: 384314
Coverity-Id: 383835
Coverity-Id: 383784
Change-Id: Icdacf8e003fd3a6ac8fd260ed335239a59de3295
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit af6b6c8e7cd5ba13a7175db890b21970a1ff82d4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ulf Hermann 2022-07-04 10:56:46 +02:00 committed by Qt Cherry-pick Bot
parent 4c0bbf5179
commit 17279d25a9

View File

@ -1924,7 +1924,7 @@ QStringConverter::QStringConverter(const char *name, Flags f)
{
auto e = encodingForName(name);
if (e)
iface = encodingInterfaces + int(e.value());
iface = encodingInterfaces + int(*e);
#if QT_CONFIG(icu)
else
iface = QStringConverterICU::make_icu_converter(&state, name);