diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2010-04-21 07:14:07 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2010-04-21 07:14:07 (GMT) |
commit | d420eb68b9a306f0fccf3000a8af31aa00cb0cd9 (patch) | |
tree | 44c958741cd0189acd5ac875d57d28165f051aae /src/script/api/qscriptengine.cpp | |
parent | 202af3021362d3c8066bc479a95e7aad889bd928 (diff) | |
parent | b72f9dacb352aa4be888c5f7f1a482dbcba1f456 (diff) | |
download | Qt-d420eb68b9a306f0fccf3000a8af31aa00cb0cd9.zip Qt-d420eb68b9a306f0fccf3000a8af31aa00cb0cd9.tar.gz Qt-d420eb68b9a306f0fccf3000a8af31aa00cb0cd9.tar.bz2 |
Merge branch '4.7' of git@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.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 7e83277..0b8a2e4 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -792,6 +792,7 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS if ((args.size() > 2) && !args.at(2).isNumber()) return JSC::throwError(exec, JSC::GeneralError, "qsTr(): third argument (n) must be a number"); #ifndef QT_NO_QOBJECT + QScriptEnginePrivate *engine = scriptEngineFromExec(exec); JSC::UString context; // The first non-empty source URL in the call stack determines the translation context. { @@ -799,7 +800,7 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS while (frame) { if (frame->codeBlock() && frame->codeBlock()->source() && !frame->codeBlock()->source()->url().isEmpty()) { - context = QFileInfo(frame->codeBlock()->source()->url()).baseName(); + context = engine->translationContextFromUrl(frame->codeBlock()->source()->url()); break; } frame = frame->callerFrame()->removeHostCallFrameFlag(); @@ -921,6 +922,8 @@ QScriptEnginePrivate::QScriptEnginePrivate() activeAgent = 0; agentLineNumber = -1; processEventsInterval = -1; + cachedTranslationUrl = JSC::UString(); + cachedTranslationContext = JSC::UString(); JSC::setCurrentIdentifierTable(oldTable); } @@ -3307,6 +3310,15 @@ bool QScriptEnginePrivate::hasDemarshalFunction(int type) const return info && (info->demarshal != 0); } +JSC::UString QScriptEnginePrivate::translationContextFromUrl(const JSC::UString &url) +{ + if (url != cachedTranslationUrl) { + cachedTranslationContext = QFileInfo(url).baseName(); + cachedTranslationUrl = url; + } + return cachedTranslationContext; +} + /*! \internal */ |