Protect the context from being GCed (#2127)

* Protect the context from being GCed
This commit is contained in:
Kenneth Geisshirt 2018-11-22 16:12:58 +01:00 committed by GitHub
parent 85a92ca85c
commit b49f2f594b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -9,6 +9,7 @@ x.x.x Release notes (yyyy-MM-dd)
* Prevent automatic token refreshes for Realms that have been closed. Previously, these could have resulted in obscure `Unhandled session token refresh error` messages in the logs that were benign. ([#2119](https://github.com/realm/realm-js/pull/2119))
* When trying to debug, users could experience a crash with the message `this._constructor is not a function`. (https://github.com/realm/realm-js/issues/491#issuecomment-438688937, since v2.19.0-rc.4)
* Check the correct name when automatically adding the permission object schemas to the schema for query-based sync realms so that defining types with the same name works correctly. ([#2121](https://github.com/realm/realm-js/pull/2121), since 2.15.0)
* Fixes a bug where the JS engine might garbage collect an object prematurely leading to a native crash. ([#496](https://github.com/realm/realm-js-private/issues/496), since v2.19.0)
### Compatibility
* Realm Object Server: 3.11.0 or later.

View File

@ -890,7 +890,7 @@ void RealmClass<T>::async_open_realm(ContextType ctx, ObjectType this_object, Ar
realm->close();
// Reopen it with the real configuration and pass that Realm back to the callback
auto final_realm = create_shared_realm(ctx, std::move(config),
auto final_realm = create_shared_realm(protected_ctx, std::move(config),
schema_updated, std::move(defaults),
std::move(constructors));
ObjectType object = create_object<T, RealmClass<T>>(protected_ctx, new SharedRealm(final_realm));