Small exception handling fixes
authorSimon Hausmann <simon.hausmann@digia.com>
Tue, 21 May 2013 08:17:30 +0000 (10:17 +0200)
committerLars Knoll <lars.knoll@digia.com>
Tue, 21 May 2013 08:36:47 +0000 (10:36 +0200)
* Don't accept the exception if we're going to re-throw it (partial unwind
is not necessary as we don't have a stack-based context to clean up)
* However do accept() it if we decided to handle it (in qqmlvme.cpp)

Change-Id: I63bfa34f30fe19ad36de746b1f15fc6b641e563b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/imports/localstorage/plugin.cpp
src/qml/qml/qqmlvme.cpp

index 7ce4f43..998155d 100644 (file)
@@ -343,11 +343,9 @@ static QV4::Value qmlsqldatabase_changeVersion(const v8::Arguments& args)
 
         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);
+        } catch (QV4::Exception &) {
             db.rollback();
             throw;
         }
@@ -397,12 +395,10 @@ static QV4::Value qmlsqldatabase_transaction_shared(const v8::Arguments& args, b
     db.transaction();
     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);
+        } catch (QV4::Exception &) {
             q->inTransaction = false;
             db.rollback();
             throw;
@@ -684,14 +680,8 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args)
     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;
-            }
+            f->call(engine->global(), args, 1);
         }
     }
 
index af4394b..6636e60 100644 (file)
@@ -1245,6 +1245,7 @@ QV4::PersistentValue QQmlVME::run(QQmlContextData *parentCtxt, QQmlScriptData *s
     try {
         script->m_program->Run(qmlglobal);
     } catch (QV4::Exception &e) {
+        e.accept(ctx);
         QQmlError error;
         QQmlExpressionPrivate::exceptionToError(e, error);
         if (error.isValid())