From b15e66d188616f8ccde79fad587809a94f7400bb Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 22 Jun 2010 01:55:53 +0000 Subject: [PATCH] javascript dataengines now actually work svn path=/trunk/KDE/kdebase/runtime/; revision=1141016 --- .../javascript/javascriptdataengine.cpp | 17 +++++++++-------- scriptengines/javascript/javascriptdataengine.h | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/scriptengines/javascript/javascriptdataengine.cpp b/scriptengines/javascript/javascriptdataengine.cpp index c98e43912..f5be7b58b 100644 --- a/scriptengines/javascript/javascriptdataengine.cpp +++ b/scriptengines/javascript/javascriptdataengine.cpp @@ -43,9 +43,9 @@ bool JavaScriptDataEngine::init() bindI18N(m_qscriptEngine); - QScriptValue iface = m_qscriptEngine->newQObject(this); - iface.setScope(global); - global.setProperty("engine", iface); + m_iface = m_qscriptEngine->newQObject(this); + m_iface.setScope(global); + global.setProperty("engine", m_iface); global.setProperty("setData", m_qscriptEngine->newFunction(JavaScriptDataEngine::jsSetData)); global.setProperty("removeAllData", m_qscriptEngine->newFunction(JavaScriptDataEngine::jsRemoveAllData)); @@ -55,11 +55,11 @@ bool JavaScriptDataEngine::init() registerDataEngineMetaTypes(m_qscriptEngine); Authorization auth; - if (!m_env->importExtensions(description(), iface, auth)) { + if (!m_env->importExtensions(description(), m_iface, auth)) { return false; } - return true; + return m_env->include(mainScript()); } void JavaScriptDataEngine::jsSetMaxSourceCount(int count) @@ -200,11 +200,12 @@ QScriptValue JavaScriptDataEngine::jsRemoveAllSources(QScriptContext *context, Q QScriptValue JavaScriptDataEngine::callFunction(const QString &functionName, const QScriptValueList &args) const { - QScriptValue fun = iface.property(functionName); + //kDebug() << "calling" << functionName; + QScriptValue fun = m_iface.property(functionName); if (fun.isFunction()) { QScriptContext *ctx = m_qscriptEngine->pushContext(); - ctx->setActivationObject(iface); - QScriptValue rv = fun.call(iface, args); + ctx->setActivationObject(m_iface); + QScriptValue rv = fun.call(m_iface, args); m_qscriptEngine->popContext(); if (m_qscriptEngine->hasUncaughtException()) { diff --git a/scriptengines/javascript/javascriptdataengine.h b/scriptengines/javascript/javascriptdataengine.h index 3dfdb9b0d..700fb244d 100644 --- a/scriptengines/javascript/javascriptdataengine.h +++ b/scriptengines/javascript/javascriptdataengine.h @@ -65,7 +65,7 @@ private: QScriptEngine *m_qscriptEngine; ScriptEnv *m_env; - QScriptValue iface; + QScriptValue m_iface; int m_pollingInterval; };