report and clear exceptions, even when caused by a method connected to a signal

BUG:234811

svn path=/trunk/KDE/kdebase/runtime/; revision=1124155
This commit is contained in:
Aaron J. Seigo 2010-05-07 23:37:25 +00:00
parent e11acef040
commit d1451eeca0
5 changed files with 18 additions and 0 deletions

View File

@ -198,6 +198,7 @@ QScriptValue JavaScriptDataEngine::callFunction(const QString &functionName, con
if (m_qscriptEngine->hasUncaughtException()) {
reportError(m_env, false);
m_qscriptEngine->clearExceptions();
} else {
return rv;
}

View File

@ -99,6 +99,7 @@ void JavaScriptRunner::match(Plasma::RunnerContext &search)
if (m_engine->hasUncaughtException()) {
reportError(m_env, false);
m_engine->clearExceptions();
}
}
@ -121,6 +122,7 @@ void JavaScriptRunner::exec(const Plasma::RunnerContext *search, const Plasma::Q
if (m_engine->hasUncaughtException()) {
reportError(m_env, false);
m_engine->clearExceptions();
}
}

View File

@ -54,6 +54,7 @@ ScriptEnv::ScriptEnv(QObject *parent, QScriptEngine *engine)
// property is hidden from scripts.
global.setProperty("__plasma_scriptenv", m_engine->newQObject(this),
QScriptValue::ReadOnly|QScriptValue::Undeletable|QScriptValue::SkipInEnumeration);
connect(m_engine, SIGNAL(signalHandlerException(QScriptValue)), this, SLOT(signalException()));
}
ScriptEnv::~ScriptEnv()
@ -71,6 +72,11 @@ ScriptEnv *ScriptEnv::findScriptEnv(QScriptEngine *engine)
return qscriptvalue_cast<ScriptEnv*>(global.property("__plasma_scriptenv"));
}
void ScriptEnv::signalException()
{
checkForErrors(false);
}
void ScriptEnv::registerEnums(QScriptValue &scriptValue, const QMetaObject &meta)
{
//manually create enum values. ugh
@ -114,6 +120,9 @@ bool ScriptEnv::checkForErrors(bool fatal)
{
if (m_engine->hasUncaughtException()) {
emit reportError(this, fatal);
if (!fatal) {
m_engine->clearExceptions();
}
return true;
}

View File

@ -68,6 +68,11 @@ private:
static QScriptValue openUrl(QScriptContext *context, QScriptEngine *engine);
static QScriptValue getUrl(QScriptContext *context, QScriptEngine *engine);
private Q_SLOTS:
void signalException();
private:
QSet<QString> m_extensions;
AllowedUrls m_allowedUrls;
QScriptEngine *m_engine;

View File

@ -244,6 +244,7 @@ void SimpleJavaScriptApplet::callFunction(QScriptValue &func, const QScriptValue
if (m_engine->hasUncaughtException()) {
reportError(m_env);
m_engine->clearExceptions();
}
}