make it possible to check for errors externally
svn path=/trunk/KDE/kdebase/runtime/; revision=1101327
This commit is contained in:
parent
2003e72a37
commit
39088b5cd4
@ -65,7 +65,7 @@ QScriptEngine *ScriptEnv::engine() const
|
||||
return m_engine;
|
||||
}
|
||||
|
||||
ScriptEnv *ScriptEnv::findScriptEnv( QScriptEngine *engine )
|
||||
ScriptEnv *ScriptEnv::findScriptEnv(QScriptEngine *engine)
|
||||
{
|
||||
QScriptValue global = engine->globalObject();
|
||||
return qscriptvalue_cast<ScriptEnv*>(global.property("__plasma_scriptenv"));
|
||||
@ -106,12 +106,17 @@ bool ScriptEnv::include(const QString &path)
|
||||
|
||||
m_engine->evaluate(script, path);
|
||||
|
||||
return !checkForErrors(true);
|
||||
}
|
||||
|
||||
bool ScriptEnv::checkForErrors(bool fatal)
|
||||
{
|
||||
if (m_engine->hasUncaughtException()) {
|
||||
emit reportError(this, true);
|
||||
return false;
|
||||
emit reportError(this, fatal);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
QScriptValue ScriptEnv::runApplication(QScriptContext *context, QScriptEngine *engine)
|
||||
@ -272,8 +277,7 @@ bool ScriptEnv::importExtensions(const KPluginInfo &info, QScriptValue &obj, Aut
|
||||
}
|
||||
}
|
||||
|
||||
if (m_engine->hasUncaughtException()) {
|
||||
emit reportError(this, true);
|
||||
if (checkForErrors(true)) {
|
||||
return false;
|
||||
} else {
|
||||
m_extensions << extension;
|
||||
@ -299,9 +303,7 @@ bool ScriptEnv::importExtensions(const KPluginInfo &info, QScriptValue &obj, Aut
|
||||
}
|
||||
}
|
||||
|
||||
if (m_engine->hasUncaughtException()) {
|
||||
emit reportError(this, false);
|
||||
} else {
|
||||
if (!checkForErrors(false)) {
|
||||
m_extensions << extension;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
QScriptEngine *engine() const;
|
||||
|
||||
/** Returns the ScriptEnv in use for a given QScriptEngine or 0. */
|
||||
static ScriptEnv *findScriptEnv( QScriptEngine *engine );
|
||||
static ScriptEnv *findScriptEnv(QScriptEngine *engine);
|
||||
|
||||
void registerEnums(QScriptValue &scriptValue, const QMetaObject &meta);
|
||||
bool include(const QString &path);
|
||||
@ -52,6 +52,8 @@ public:
|
||||
bool importExtensions(const KPluginInfo &info, QScriptValue &obj, Authorization &authorizer);
|
||||
QSet<QString> loadedExtensions() const;
|
||||
|
||||
bool checkForErrors(bool fatal);
|
||||
|
||||
Q_SIGNALS:
|
||||
void reportError(ScriptEnv *engine, bool fatal);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user