aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-10-23 18:26:38 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-10-24 16:44:54 +0000
commit5fc4c09a958c5f78aa9f69cee2c45eef9a5166b8 (patch)
tree1ae0189f3863a263251141cf930988de45f1642d /src/qml/jsruntime
parent377815ca88cf99089f0d62e2822ff8a4cdba2895 (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. Pick-to: 6.6 6.5 Fixes: QTBUG-118469 Change-Id: I160c512f42aba4a8ae2fc8860cdf4e50c53d9d3e Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp
index 9b4b2353c5..bd43d3cb97 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit.cpp
+++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp
@@ -974,11 +974,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
}