From dfbb731676e59b42f548dfca15e60f08cfcdc2f5 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Wed, 29 May 2013 15:21:59 +0200 Subject: 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 --- src/libs/installer/scriptengine.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libs/installer/scriptengine.cpp') 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 -- cgit v1.2.3