don't reset delegate when refetching an existing realm

This commit is contained in:
Ari Lazier 2015-09-09 17:30:42 -07:00
parent 18811f294f
commit 51e0551548

View File

@ -157,9 +157,11 @@ JSObjectRef RealmConstructor(JSContextRef ctx, JSObjectRef constructor, size_t a
*jsException = RJSMakeError(ctx, "Invalid arguments when constructing 'Realm'");
return NULL;
}
SharedRealm *realm = new SharedRealm(Realm::get_shared_realm(config));
(*realm)->m_delegate = std::make_unique<RJSRealmDelegate>();
return RJSWrapObject<SharedRealm *>(ctx, RJSRealmClass(), realm);
SharedRealm realm = Realm::get_shared_realm(config);
if (!realm->m_delegate) {
realm->m_delegate = std::make_unique<RJSRealmDelegate>();
}
return RJSWrapObject<SharedRealm *>(ctx, RJSRealmClass(), new SharedRealm(realm));
}
catch (std::exception &ex) {
if (jsException) {