From e2c1e7b8a274b2b00e19f00f0c24d9b17810f603 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 5 Jan 2015 15:31:20 +0100 Subject: Print exceptions in JS slots Do print JS exceptions raised in slots to the console, and clear the status afterwards. Otherwise exceptions raised might silently propagate to later JS calls. Change-Id: I122f3026aa18028415c5a4672cb3287e7d58ac4d Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4qobjectwrapper.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index f2c30e618f..db1315dc87 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -802,13 +802,17 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase f->call(callData); if (scope.hasException() && v4->v8Engine) { + QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx); + if (error.description().isEmpty()) { + QV4::ScopedString name(scope, f->name()); + error.setDescription(QString::fromLatin1("Unknown exception occurred during evaluation of connected function: %1").arg(name->toQString())); + } if (QQmlEngine *qmlEngine = v4->v8Engine->engine()) { - QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx); - if (error.description().isEmpty()) { - QV4::ScopedString name(scope, f->name()); - error.setDescription(QString(QLatin1String("Unknown exception occurred during evaluation of connected function: %1")).arg(name->toQString())); - } QQmlEnginePrivate::get(qmlEngine)->warning(error); + } else { + QMessageLogger(error.url().toString().toLatin1().constData(), + error.line(), 0).warning().noquote() + << error.toString(); } } } -- cgit v1.2.3