From 0869219f0f58ad93149e416016b0b880d79bae47 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 2 Jul 2009 11:42:58 +0200 Subject: create a new QScriptContext when calling a Qt method Makes the args, thisObject etc. available if QScriptable is used. --- src/script/bridge/qscriptqobject.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index 0162b63..ae7a75b 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -19,6 +19,7 @@ #include #include "../api/qscriptengine_p.h" #include "../api/qscriptable_p.h" +#include "../api/qscriptcontext_p.h" #include "Error.h" #include "PrototypeFunction.h" @@ -917,11 +918,22 @@ JSC::JSValue QtFunction::call(JSC::ExecState *exec, JSC::JSValue thisValue, const JSC::ClassInfo QtFunction::info = { "QtFunction", 0, 0, 0 }; JSC::JSValue QtFunction_call(JSC::ExecState *exec, JSC::JSObject *callee, - JSC::JSValue thisValue, const JSC::ArgList &args) + JSC::JSValue thisValue, const JSC::ArgList &args) { if (!callee->isObject(&QtFunction::info)) return throwError(exec, JSC::TypeError); - return static_cast(callee)->call(exec, thisValue, args); + QtFunction *qfun = static_cast(callee); + QScriptEnginePrivate *eng_p = static_cast(exec->dynamicGlobalObject())->engine; + QScriptContext *previousContext = eng_p->currentContext; + QScriptContextPrivate ctx_p(callee, thisValue, args, + /*calledAsConstructor=*/false, + previousContext, eng_p); + QScriptContext *ctx = QScriptContextPrivate::create(ctx_p); + eng_p->currentContext = ctx; + JSC::JSValue result = qfun->call(exec, thisValue, args); + eng_p->currentContext = previousContext; + delete ctx; + return result; } const JSC::ClassInfo QObjectWrapperObject::info = { "QObject", 0, 0, 0 }; -- cgit v0.12