include files in the caller's context
svn path=/branches/KDE/4.4/kdebase/runtime/; revision=1075375
This commit is contained in:
parent
8a90de27ef
commit
35249faad6
@ -281,7 +281,16 @@ bool SimpleJavaScriptApplet::include(const QString &path)
|
||||
QString script = file.readAll();
|
||||
//kDebug() << "Script says" << script;
|
||||
|
||||
m_engine->evaluate(script);
|
||||
// change the context to the parent context so that the include is actually
|
||||
// executed in the same context as the caller; seems to be what javascript
|
||||
// coders expect :)
|
||||
QScriptContext *ctx = m_engine->currentContext();
|
||||
if (ctx && ctx->parentContext()) {
|
||||
ctx->setActivationObject(ctx->parentContext()->activationObject());
|
||||
ctx->setThisObject(ctx->parentContext()->thisObject());
|
||||
}
|
||||
|
||||
m_engine->evaluate(script, path);
|
||||
if (m_engine->hasUncaughtException()) {
|
||||
reportError(m_engine, true);
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user