summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/scriptengine.cpp
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@digia.com>2013-05-29 15:21:59 +0200
committerTim Jenssen <tim.jenssen@digia.com>2013-06-03 16:35:28 +0200
commitdfbb731676e59b42f548dfca15e60f08cfcdc2f5 (patch)
tree99f790422f6e1fe6af404dfe78c082fa5656eb70 /src/libs/installer/scriptengine.cpp
parentc2cfa6dd833f60d75cc7aafe7282d052cdae5257 (diff)
add exceptionhandler code for connected signals/JS methods
- there wasn't any error information if a C++ triggered signal resulted in a JS method which has an error, now it will create an exception for it - creating messagebox inside the lib is something what we want to avoid, so the developer itself is responsible to catch these exceptions - most cases of the installer code does that already Change-Id: I07486f73be9de13a486de235f14e3a7d7b54f5b1 Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Diffstat (limited to 'src/libs/installer/scriptengine.cpp')
-rw-r--r--src/libs/installer/scriptengine.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp
index 6178f467f..9ff8ae75e 100644
--- a/src/libs/installer/scriptengine.cpp
+++ b/src/libs/installer/scriptengine.cpp
@@ -209,6 +209,8 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core)
globalObject().property(QLatin1String("installer"))
.setProperty(QLatin1String("components"), scriptComponentsObject);
+
+ connect(this, SIGNAL(signalHandlerException(QScriptValue)), SLOT(handleException(QScriptValue)));
}
ScriptEngine::~ScriptEngine()
@@ -279,6 +281,12 @@ QScriptValue ScriptEngine::loadInConext(const QString &context, const QString &f
return scriptContext;
}
+void ScriptEngine::handleException(const QScriptValue &value)
+{
+ if (!value.engine())
+ return;
+ throw Error(uncaughtExceptionString(this, tr("Fatal error while evaluating a script.")));
+}
/*!
Tries to call the method with \a name within the script and returns the result. If the method