diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-07 12:23:17 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-07 14:40:41 +0100 |
commit | 7f0faa7fb56435ab515a6178892c420b595a899f (patch) | |
tree | c50c52602ea4bf77af5f98b2df8749b3d29863ed /src/qml/jsruntime | |
parent | 5f6436e474624997b284547e4ee117fb49d29e79 (diff) |
Fix exception thrown in slot without Qml Engine
Don't crash when an exception is thrown in a JS slot but we don't have
a Qml engine.
Change-Id: I1530d5c1c8cb9b9b33b9fdd0d45639fd4a0516f7
Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index cd0c81846c..e40875dff3 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -778,11 +778,13 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase } f->call(callData); - if (scope.hasException()) { - QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx); - if (error.description().isEmpty()) - error.setDescription(QString(QLatin1String("Unknown exception occurred during evaluation of connected function: %1")).arg(f->name->toQString())); - QQmlEnginePrivate::get(v4->v8Engine->engine())->warning(error); + if (scope.hasException() && v4->v8Engine) { + if (QQmlEngine *qmlEngine = v4->v8Engine->engine()) { + QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx); + if (error.description().isEmpty()) + error.setDescription(QString(QLatin1String("Unknown exception occurred during evaluation of connected function: %1")).arg(f->name->toQString())); + QQmlEnginePrivate::get(qmlEngine)->warning(error); + } } } break; |