From 00b1ff4607a560a2df674d56a70ecf3bd3e4f3df Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 6 Nov 2018 10:07:43 +0100 Subject: Fix translation bindings when qtquickcompiler is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It turns out that the context information is lost when using the compiler. The unit->unitData()->sourceFileIndex is wrong (always 0), which should probably be fixed. This change only works around that by using unit->fileName(); instead. Make sure that the test actually verifies translations happen and have a context. Done-with: Jan Arve Sæther Fixes: QTBUG-71553 Change-Id: Ib5926bd4b9a6267644f5c9328a84c23d61ca5466 Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4compileddata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/compiler') diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 39f48f67f8..4b5d5dc96d 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -730,7 +730,7 @@ QString Binding::valueAsString(const CompilationUnit *unit) const case Type_Translation: { const TranslationData &translation = unit->unitData()->translations()[value.translationDataIndex]; // This code must match that in the qsTr() implementation - const QString &path = unit->stringAt(unit->unitData()->sourceFileIndex); + const QString &path = unit->fileName(); int lastSlash = path.lastIndexOf(QLatin1Char('/')); QStringRef context = (lastSlash > -1) ? path.midRef(lastSlash + 1, path.length() - lastSlash - 5) : QStringRef(); -- cgit v1.2.3