aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2013-12-02 17:25:23 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-04 00:37:29 +0100
commit4d3a654dddbb648be97fe52c695601f6864f72a1 (patch)
treeb321371a7777d1cf44e82396c90f2fc5feb8f874 /src/qml/qml
parentcf51cdb8fb002ae3602a4c886e7c67913d77373a (diff)
Fix qsTr() in .js context
Don't assume a four characters long file name suffix (.qml) Task-number: QTBUG-32850 Change-Id: I522c06b71bf1b38f32f2947a6c06017f83eb50be Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index c80a742af0..bbb07cf332 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -1726,7 +1726,9 @@ ReturnedValue GlobalExtensions::method_qsTr(CallContext *ctx)
QString path = ctxt->url.toString();
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
- QString context = (lastSlash > -1) ? path.mid(lastSlash + 1, path.length()-lastSlash-5) : QString();
+ int lastDot = path.lastIndexOf(QLatin1Char('.'));
+ int length = lastDot - (lastSlash + 1);
+ QString context = (lastSlash > -1) ? path.mid(lastSlash + 1, (length > -1) ? length : -1) : QString();
QString text = ctx->callData->args[0].toQStringNoThrow();
QString comment;