summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptengine.cpp
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2010-04-15 18:31:55 (GMT)
committerDavid Boddie <dboddie@trolltech.com>2010-04-15 18:31:55 (GMT)
commita45120bee778f0a04772d37a41790b50d97a1aec (patch)
treec1ae734aa4b938521ae37ffbb00eb5df17b0bf79 /src/script/api/qscriptengine.cpp
parent5b975e1dc61eaee055afc40fef13358bcd55c7d2 (diff)
parentd03c27040c08827eddbb086f70a50f8b908f97cc (diff)
downloadQt-a45120bee778f0a04772d37a41790b50d97a1aec.zip
Qt-a45120bee778f0a04772d37a41790b50d97a1aec.tar.gz
Qt-a45120bee778f0a04772d37a41790b50d97a1aec.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'src/script/api/qscriptengine.cpp')
-rw-r--r--src/script/api/qscriptengine.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 58c8d83..f732907 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, "qsTranslate(): 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
*/