diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-10-22 14:32:03 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-29 10:39:04 +0100 |
commit | 25fbdfc66fa995bfe633b3c31d635045f7cf66dd (patch) | |
tree | 3264a851680476ebb7f161d5a38dcff3182a0e8a /src/qml/jsruntime | |
parent | ffcdbfa03f8bb36b521f8c1a703ee24085fe25bd (diff) |
Fix the remaining try/catch statements in C++
Change-Id: I2421dc48fb271b66bd476fb16a32a88fcc4c5177
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4include.cpp | 12 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 5 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4serialize.cpp | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value.cpp | 20 |
4 files changed, 19 insertions, 26 deletions
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 355817ef3e..40f7b865d0 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -109,14 +109,12 @@ void QV4Include::callback(const QV4::ValueRef callback, const QV4::ValueRef stat return; QV4::ExecutionContext *ctx = v4->current; - try { - QV4::ScopedCallData callData(scope, 1); - callData->thisObject = v4->globalObject->asReturnedValue(); - callData->args[0] = status; - f->call(callData); - } catch (...) { + QV4::ScopedCallData callData(scope, 1); + callData->thisObject = v4->globalObject->asReturnedValue(); + callData->args[0] = status; + f->call(callData); + if (scope.hasException()) ctx->catchException(); - } } QV4::ReturnedValue QV4Include::result() diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index acdfc1ba52..a4bfc93c36 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -727,9 +727,8 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase } } - try { - f->call(callData); - } catch (...) { + 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())); diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp index 53d7e4701a..88e7630055 100644 --- a/src/qml/jsruntime/qv4serialize.cpp +++ b/src/qml/jsruntime/qv4serialize.cpp @@ -280,12 +280,10 @@ void Serialize::serialize(QByteArray &data, const QV4::ValueRef v, QV8Engine *en serialize(data, s, engine); QV4::ExecutionContext *ctx = v4->current; - try { - str = s; - val = o->get(str); - } catch (...) { + str = s; + val = o->get(str); + if (scope.hasException()) ctx->catchException(); - } serialize(data, val, engine); } diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index ebd1894016..a7413e031c 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -125,22 +125,20 @@ QString Value::toQStringNoThrow() const Scope scope(ctx); ScopedValue ex(scope); bool caughtException = false; - try { - ScopedValue prim(scope, __qmljs_to_primitive(ValueRef::fromRawValue(this), STRING_HINT)); - if (prim->isPrimitive()) - return prim->toQStringNoThrow(); - } catch (...) { + ScopedValue prim(scope, __qmljs_to_primitive(ValueRef::fromRawValue(this), STRING_HINT)); + if (scope.hasException()) { ex = ctx->catchException(); caughtException = true; + } else if (prim->isPrimitive()) { + return prim->toQStringNoThrow(); } // Can't nest try/catch due to CXX ABI limitations for foreign exception nesting. if (caughtException) { - try { - ScopedValue prim(scope, __qmljs_to_primitive(ex, STRING_HINT)); - if (prim->isPrimitive()) - return prim->toQStringNoThrow(); - } catch(...) { - ctx->catchException(); + ScopedValue prim(scope, __qmljs_to_primitive(ex, STRING_HINT)); + if (scope.hasException()) { + ex = ctx->catchException(); + } else if (prim->isPrimitive()) { + return prim->toQStringNoThrow(); } } return QString(); |