summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-11-27 20:06:25 +0100
committerMarc Mutz <[email protected]>2025-11-28 23:33:09 +0000
commitfa851e768872c08c177db019931a2df0b8f74c65 (patch)
tree77da6518fe62f36f2f5b0694ddfcc9c9c2b0ff7e /src
parentce4969e404c493727831a626087cfbe331783701 (diff)
QFont: fix a QT_ASCII_CAST_WARN
Says GCC: qfont.cpp:2202:81: required from here 2202 | fontDescription += comma + tag.toString() + u'=' + QString::number(value); | ^ qstringbuilder.h:403:37: warning: ‘static void QConcatenable<QByteArray>::appendTo(const QByteArray&, QChar*&)’ is deprecated: Use fromUtf8, QStringLiteral, or QLatin1StringView [-Wdeprecated-declarations] 403 | QConcatenableEx<B>::appendTo(p.b, out); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ qstringbuilder.h:372:43: note: declared here 372 | QT_ASCII_CAST_WARN static inline void appendTo(const QByteArray &ba, QChar *&out) | ^~~~~~~~ This is because Tag::toString() returns QByteArray, not QString. To fix, wrap the toString() result in QLatin1StringView. This is safe, because the temporary QByteArray will be kept alive until the end of the full-expression, so until after op+= has executed. It does change the serialization vis-a-vis the old code, but a) only for non-US-ASCII tags, which are not really valid, and b) we make it more robust now, because each random 4-octet sequence is a valid L1 string, but many are not valid UTF-8, so their interpretation as U8 by the old code (QByteArray → QString assumes U8) depends on behavior of Qt outside its spec. GIGO applies, of course, but we don't tend to specify the GO for any given GI, so it's better to use an algorithm for which no input is "garbage". Amends 8fe6ad3eed40a8c851bf5d49e322f9794b9f7dcf. Task-number: QTBUG-141412 Change-Id: Ic45f9147ca54201a33d953da57b768d2a5d115e4 Reviewed-by: Ahmad Samir <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qfont.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index b60cad34a8d..2b2f2a27fcd 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -2201,7 +2201,7 @@ QString QFont::toString() const
fontDescription += comma + QString::number(sortedFeatures.size());
for (const auto &[tag, value] : std::as_const(sortedFeatures).asKeyValueRange())
- fontDescription += comma + tag.toString() + u'=' + QString::number(value);
+ fontDescription += comma + QLatin1StringView{tag.toString()} + u'=' + QString::number(value);
return fontDescription;
}