aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/debugger/qqmldebugserviceinterfaces.cpp
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/debugger/qqmldebugserviceinterfaces.cpp
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/debugger/qqmldebugserviceinterfaces.cpp')
-rw-r--r--src/qml/debugger/qqmldebugserviceinterfaces.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/qml/debugger/qqmldebugserviceinterfaces.cpp b/src/qml/debugger/qqmldebugserviceinterfaces.cpp
index 9ef5058803..1dc0a3556f 100644
--- a/src/qml/debugger/qqmldebugserviceinterfaces.cpp
+++ b/src/qml/debugger/qqmldebugserviceinterfaces.cpp
@@ -66,14 +66,17 @@ const TranslationBindingInformation TranslationBindingInformation::create(
compilationUnit->data->translations()[binding->value.translationDataIndex];
const QString text = compilationUnit->stringAt(data.stringIndex);
const QString comment = compilationUnit->stringAt(data.commentIndex);
- const QString context = compilationUnit->stringAt(data.contextIndex);
+ const bool hasContext
+ = data.contextIndex != QV4::CompiledData::TranslationData::NoContextIndex;
const int n = data.number;
translation = QQmlTranslation(
- QQmlTranslation::QsTrData(context.isEmpty()
- ? QQmlTranslation::contextFromQmlFilename(
- compilationUnit->fileName())
- : context, text, comment, n));
+ QQmlTranslation::QsTrData(
+ hasContext
+ ? compilationUnit->stringAt(data.contextIndex)
+ : QQmlTranslation::contextFromQmlFilename(
+ compilationUnit->fileName()),
+ text, comment, n));
}
return { compilationUnit,