aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-05-20 22:12:41 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-05-21 10:10:15 +0200
commite1a6612d3a4528fee8854c274232fc4966d65237 (patch)
tree7015b2768eca50f9ca7b8edc6c842894b345fa20 /src/imports
parent71e263abc4c5fe0941c931f6a38b394db75b1027 (diff)
Remove half the v8::TryCatch statements
Replacing the other half requires a replacement for v8::Script. Change-Id: I40fe99302fba23f286773ec1adaf8d3751db901d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/localstorage/localstorage.pro1
-rw-r--r--src/imports/localstorage/plugin.cpp62
2 files changed, 37 insertions, 26 deletions
diff --git a/src/imports/localstorage/localstorage.pro b/src/imports/localstorage/localstorage.pro
index 15753263b8..d3e7182a3b 100644
--- a/src/imports/localstorage/localstorage.pro
+++ b/src/imports/localstorage/localstorage.pro
@@ -4,6 +4,7 @@ TARGETPATH = QtQuick/LocalStorage
IMPORT_VERSION = 2.0
QT = sql qml-private core-private
+CONFIG += exceptions
SOURCES += plugin.cpp
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index f5627984d8..7ce4f43b9d 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -341,15 +341,17 @@ static QV4::Value qmlsqldatabase_changeVersion(const v8::Arguments& args)
ok = false;
db.transaction();
- v8::TryCatch tc;
- v8::Handle<v8::Value> callbackArgs[] = { instance };
- v8::Handle<v8::Function>::Cast(callback)->Call(v8::Value::fromV4Value(engine->global()), 1, callbackArgs);
-
- if (tc.HasCaught()) {
+ QV4::Value callbackArgs[] = { instance->v4Value() };
+ QV4::FunctionObject *f = callback->v4Value().asFunctionObject();
+ QV4::ExecutionContext *ctx = f->engine()->current;
+ try {
+ f->call(engine->global(), callbackArgs, 1);
+ } catch (QV4::Exception &e) {
+ e.accept(ctx);
db.rollback();
- tc.ReThrow();
- return QV4::Value::undefinedValue();
- } else if (!db.commit()) {
+ throw;
+ }
+ if (!db.commit()) {
db.rollback();
V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR,QQmlEngine::tr("SQL transaction failed"));
} else {
@@ -393,18 +395,23 @@ static QV4::Value qmlsqldatabase_transaction_shared(const v8::Arguments& args, b
instance->SetExternalResource(q);
db.transaction();
- v8::TryCatch tc;
- v8::Handle<v8::Value> callbackArgs[] = { instance };
- callback->Call(v8::Value::fromV4Value(engine->global()), 1, callbackArgs);
+ QV4::FunctionObject *f = callback->v4Value().asFunctionObject();
+ if (f) {
+ QV4::ExecutionContext *ctx = f->engine()->current;
+ QV4::Value callbackArgs[] = { instance->v4Value() };
+ try {
+ f->call(engine->global(), callbackArgs, 1);
+ } catch (QV4::Exception &e) {
+ e.accept(ctx);
+ q->inTransaction = false;
+ db.rollback();
+ throw;
+ }
- q->inTransaction = false;
+ q->inTransaction = false;
- if (tc.HasCaught()) {
- db.rollback();
- tc.ReThrow();
- return QV4::Value::undefinedValue();
- } else if (!db.commit()) {
- db.rollback();
+ if (!db.commit())
+ db.rollback();
}
return QV4::Value::undefinedValue();
@@ -674,14 +681,17 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args)
r->version = version;
instance->SetExternalResource(r);
- if (created && dbcreationCallback->IsFunction()) {
- v8::TryCatch tc;
- v8::Handle<v8::Function> callback = v8::Handle<v8::Function>::Cast(dbcreationCallback);
- v8::Handle<v8::Value> args[] = { instance };
- callback->Call(v8::Value::fromV4Value(engine->global()), 1, args);
- if (tc.HasCaught()) {
- tc.ReThrow();
- return;
+ if (created) {
+ QV4::FunctionObject *f = dbcreationCallback->v4Value().asFunctionObject();
+ if (f) {
+ QV4::ExecutionContext *ctx = f->engine()->current;
+ QV4::Value args[] = { instance->v4Value() };
+ try {
+ f->call(engine->global(), args, 1);
+ } catch (QV4::Exception &e) {
+ e.accept(ctx);
+ throw;
+ }
}
}