add a return value to callFunction

svn path=/trunk/KDE/kdebase/runtime/; revision=1159647
This commit is contained in:
Aaron J. Seigo 2010-08-05 21:13:13 +00:00
parent 14ec881538
commit c7e5e9ce79
2 changed files with 7 additions and 4 deletions

View File

@ -502,21 +502,24 @@ QScriptValue ScriptEnv::removeEventListener(QScriptContext *context, QScriptEngi
return env->removeEventListener(context->argument(0).toString(), context->argument(1));
}
void ScriptEnv::callFunction(QScriptValue &func, const QScriptValueList &args, const QScriptValue &activator)
QScriptValue ScriptEnv::callFunction(QScriptValue &func, const QScriptValueList &args, const QScriptValue &activator)
{
if (!func.isFunction()) {
return;
return m_engine->undefinedValue();
}
QScriptContext *ctx = m_engine->pushContext();
ctx->setActivationObject(activator);
func.call(activator, args);
QScriptValue rv = func.call(activator, args);
m_engine->popContext();
if (m_engine->hasUncaughtException()) {
emit reportError(this, false);
m_engine->clearExceptions();
return m_engine->undefinedValue();
}
return rv;
}
bool ScriptEnv::hasEventListeners(const QString &event) const

View File

@ -63,7 +63,7 @@ public:
bool addEventListener(const QString &event, const QScriptValue &func);
bool removeEventListener(const QString &event, const QScriptValue &func);
void callFunction(QScriptValue &func, const QScriptValueList &args = QScriptValueList(), const QScriptValue &activator = QScriptValue());
QScriptValue callFunction(QScriptValue &func, const QScriptValueList &args = QScriptValueList(), const QScriptValue &activator = QScriptValue());
bool callEventListeners(const QString &event, const QScriptValueList &args = QScriptValueList());
bool hasEventListeners(const QString &event) const;