javascript dataengines now actually work

svn path=/trunk/KDE/kdebase/runtime/; revision=1141016
This commit is contained in:
Aaron J. Seigo 2010-06-22 01:55:53 +00:00
parent a6899cc114
commit b15e66d188
2 changed files with 10 additions and 9 deletions

View File

@ -43,9 +43,9 @@ bool JavaScriptDataEngine::init()
bindI18N(m_qscriptEngine); bindI18N(m_qscriptEngine);
QScriptValue iface = m_qscriptEngine->newQObject(this); m_iface = m_qscriptEngine->newQObject(this);
iface.setScope(global); m_iface.setScope(global);
global.setProperty("engine", iface); global.setProperty("engine", m_iface);
global.setProperty("setData", m_qscriptEngine->newFunction(JavaScriptDataEngine::jsSetData)); global.setProperty("setData", m_qscriptEngine->newFunction(JavaScriptDataEngine::jsSetData));
global.setProperty("removeAllData", m_qscriptEngine->newFunction(JavaScriptDataEngine::jsRemoveAllData)); global.setProperty("removeAllData", m_qscriptEngine->newFunction(JavaScriptDataEngine::jsRemoveAllData));
@ -55,11 +55,11 @@ bool JavaScriptDataEngine::init()
registerDataEngineMetaTypes(m_qscriptEngine); registerDataEngineMetaTypes(m_qscriptEngine);
Authorization auth; Authorization auth;
if (!m_env->importExtensions(description(), iface, auth)) { if (!m_env->importExtensions(description(), m_iface, auth)) {
return false; return false;
} }
return true; return m_env->include(mainScript());
} }
void JavaScriptDataEngine::jsSetMaxSourceCount(int count) 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 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()) { if (fun.isFunction()) {
QScriptContext *ctx = m_qscriptEngine->pushContext(); QScriptContext *ctx = m_qscriptEngine->pushContext();
ctx->setActivationObject(iface); ctx->setActivationObject(m_iface);
QScriptValue rv = fun.call(iface, args); QScriptValue rv = fun.call(m_iface, args);
m_qscriptEngine->popContext(); m_qscriptEngine->popContext();
if (m_qscriptEngine->hasUncaughtException()) { if (m_qscriptEngine->hasUncaughtException()) {

View File

@ -65,7 +65,7 @@ private:
QScriptEngine *m_qscriptEngine; QScriptEngine *m_qscriptEngine;
ScriptEnv *m_env; ScriptEnv *m_env;
QScriptValue iface; QScriptValue m_iface;
int m_pollingInterval; int m_pollingInterval;
}; };