add a return value to callFunction
svn path=/trunk/KDE/kdebase/runtime/; revision=1159647
This commit is contained in:
parent
14ec881538
commit
c7e5e9ce79
@ -502,21 +502,24 @@ QScriptValue ScriptEnv::removeEventListener(QScriptContext *context, QScriptEngi
|
|||||||
return env->removeEventListener(context->argument(0).toString(), context->argument(1));
|
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()) {
|
if (!func.isFunction()) {
|
||||||
return;
|
return m_engine->undefinedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptContext *ctx = m_engine->pushContext();
|
QScriptContext *ctx = m_engine->pushContext();
|
||||||
ctx->setActivationObject(activator);
|
ctx->setActivationObject(activator);
|
||||||
func.call(activator, args);
|
QScriptValue rv = func.call(activator, args);
|
||||||
m_engine->popContext();
|
m_engine->popContext();
|
||||||
|
|
||||||
if (m_engine->hasUncaughtException()) {
|
if (m_engine->hasUncaughtException()) {
|
||||||
emit reportError(this, false);
|
emit reportError(this, false);
|
||||||
m_engine->clearExceptions();
|
m_engine->clearExceptions();
|
||||||
|
return m_engine->undefinedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptEnv::hasEventListeners(const QString &event) const
|
bool ScriptEnv::hasEventListeners(const QString &event) const
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
bool addEventListener(const QString &event, const QScriptValue &func);
|
bool addEventListener(const QString &event, const QScriptValue &func);
|
||||||
bool removeEventListener(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 callEventListeners(const QString &event, const QScriptValueList &args = QScriptValueList());
|
||||||
bool hasEventListeners(const QString &event) const;
|
bool hasEventListeners(const QString &event) const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user