diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-04-14 08:14:40 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-04-14 08:14:40 (GMT) |
commit | 62cd360b3f2ef9e9787359a9105fd805b721b49f (patch) | |
tree | 8bb7dd87f0914d59d94d688c32e9244ebb79cbad /src/script/api | |
parent | 4af9cc043370846c52ec21cf874696ee650394c1 (diff) | |
parent | 0dbd8f1b0a6df20e5502bb35e58490a9f99953a7 (diff) | |
download | Qt-62cd360b3f2ef9e9787359a9105fd805b721b49f.zip Qt-62cd360b3f2ef9e9787359a9105fd805b721b49f.tar.gz Qt-62cd360b3f2ef9e9787359a9105fd805b721b49f.tar.bz2 |
Merge remote branch 'origin/4.6' into qt-4.7-from-4.6
Conflicts:
src/script/api/qscriptengine.cpp
Diffstat (limited to 'src/script/api')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 16 |
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 |