diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-04-15 07:06:39 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-04-15 07:06:39 (GMT) |
commit | 519bf02008b8e6f1bf5154ce5c384049c3ebb0d7 (patch) | |
tree | aa325674b7f86749d630f5eb587651007f6a10ca /src/script/api/qscriptengine.cpp | |
parent | 6e189eb28161f2d09e0c71ecd590b7ccfd82321c (diff) | |
parent | 414ff1be28af440f1e01a38e497227f3849e8e54 (diff) | |
download | Qt-519bf02008b8e6f1bf5154ce5c384049c3ebb0d7.zip Qt-519bf02008b8e6f1bf5154ce5c384049c3ebb0d7.tar.gz Qt-519bf02008b8e6f1bf5154ce5c384049c3ebb0d7.tar.bz2 |
Merge remote branch 'staging/4.7' into bearermanagement/qconfig
Diffstat (limited to 'src/script/api/qscriptengine.cpp')
-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 |