summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptengine.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-16 00:12:16 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-16 00:12:16 (GMT)
commit7b0d764f37fa4009dc1556666eb8a141164fb0e0 (patch)
tree3d5d1c0f5aadc2f3e2a5eccacd2fc2f32b21e385 /src/script/api/qscriptengine.cpp
parentbac82138b76ac9f6a0603fa454f6660d139287d0 (diff)
parent16ae00c689faac5d7af312ae31d7f715dc6e0745 (diff)
downloadQt-7b0d764f37fa4009dc1556666eb8a141164fb0e0.zip
Qt-7b0d764f37fa4009dc1556666eb8a141164fb0e0.tar.gz
Qt-7b0d764f37fa4009dc1556666eb8a141164fb0e0.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/script/api/qscriptengine.cpp')
-rw-r--r--src/script/api/qscriptengine.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 2417d80..58c8d83 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -42,6 +42,7 @@
#include <math.h>
+#include "CodeBlock.h"
#include "Error.h"
#include "JSLock.h"
#include "Interpreter.h"
@@ -792,9 +793,18 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS
return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): third argument (n) must be a number");
#ifndef QT_NO_QOBJECT
JSC::UString context;
- QScriptContext *ctx = QScriptEnginePrivate::contextForFrame(exec);
- if (ctx && ctx->parentContext())
- context = QFileInfo(QScriptContextInfo(ctx->parentContext()).fileName()).baseName();
+ // The first non-empty source URL in the call stack determines the translation context.
+ {
+ JSC::ExecState *frame = exec->removeHostCallFrameFlag();
+ while (frame) {
+ if (frame->codeBlock() && frame->codeBlock()->source()
+ && !frame->codeBlock()->source()->url().isEmpty()) {
+ context = QFileInfo(frame->codeBlock()->source()->url()).baseName();
+ break;
+ }
+ frame = frame->callerFrame()->removeHostCallFrameFlag();
+ }
+ }
#endif
JSC::UString text = args.at(0).toString(exec);
#ifndef QT_NO_QOBJECT