From 5fc4c09a958c5f78aa9f69cee2c45eef9a5166b8 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 23 Oct 2023 18:26:38 +0200 Subject: 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 Reviewed-by: Fabian Kosmale --- src/qml/debugger/qqmldebugserviceinterfaces.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/qml/debugger/qqmldebugserviceinterfaces.cpp') 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, -- cgit v1.2.3