diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2023-10-23 18:26:38 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-10-25 14:11:18 +0200 |
| commit | 5b63179a227a18550b934686ff2f5cc847efadec (patch) | |
| tree | 859b00fc29ff18596e7f72dc3161afb1b733a80a /src/qml/jsruntime/qv4executablecompilationunit.cpp | |
| parent | 4365e9ee2fc5b510b545772bf5a14f122467682d (diff) | |
Fix compile time qsTranslate with empty context
An empty context is to be passed as-is. We shall not replace it with the
file context context. Since the TranslationData struct has a field for
the context, we need to invent a "no context" value we use for the
methods that don't allow you to set a context (e.g. qsTr, qsTrId). We
cannot use 0 because that is the empty string which is a valid context
now.
Amends commit 9cfc19faf5d1ce2b9626914ab4528998b072385d.
Fixes: QTBUG-118469
Change-Id: I160c512f42aba4a8ae2fc8860cdf4e50c53d9d3e
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 5fc4c09a958c5f78aa9f69cee2c45eef9a5166b8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit a95e6dd76a54874d22ff883ea5d04d80543eae93)
Diffstat (limited to 'src/qml/jsruntime/qv4executablecompilationunit.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4executablecompilationunit.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp index 055524d8d3..7b7772d3f0 100644 --- a/src/qml/jsruntime/qv4executablecompilationunit.cpp +++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp @@ -953,11 +953,13 @@ QString ExecutableCompilationUnit::translateFrom(TranslationDataIndex index) con return context.toUtf8(); }; - QByteArray context = stringAt(translation.contextIndex).toUtf8(); + const bool hasContext + = translation.contextIndex != QV4::CompiledData::TranslationData::NoContextIndex; QByteArray comment = stringAt(translation.commentIndex).toUtf8(); QByteArray text = stringAt(translation.stringIndex).toUtf8(); return QCoreApplication::translate( - context.isEmpty() ? fileContext() : context, text, comment, translation.number); + hasContext ? stringAt(translation.contextIndex).toUtf8() : fileContext(), + text, comment, translation.number); #endif } |
