Fix for failing nested transaction test

This commit is contained in:
Scott Kyle 2016-04-18 15:11:56 -07:00
parent a0424c6600
commit fc49470b3c
1 changed files with 7 additions and 7 deletions

View File

@ -459,17 +459,17 @@ void Realm<T>::write(ContextType ctx, ObjectType this_object, size_t argc, const
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object); SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
FunctionType callback = Value::validated_to_function(ctx, arguments[0]); FunctionType callback = Value::validated_to_function(ctx, arguments[0]);
realm->begin_transaction();
try { try {
realm->begin_transaction();
Function<T>::call(ctx, callback, this_object, 0, nullptr); Function<T>::call(ctx, callback, this_object, 0, nullptr);
realm->commit_transaction();
} }
catch (std::exception &exp) { catch (std::exception &e) {
if (realm->is_in_transaction()) { realm->cancel_transaction();
realm->cancel_transaction(); throw e;
}
throw;
} }
realm->commit_transaction();
} }
template<typename T> template<typename T>