Fix another crash involving protected values

This commit is contained in:
Scott Kyle 2016-04-19 03:58:23 -07:00
parent 275334fa7e
commit 8e5afeccc9
2 changed files with 5 additions and 2 deletions

View File

@ -63,7 +63,10 @@ class RealmDelegate : public BindingContext {
RealmDelegate(std::weak_ptr<Realm> realm, GlobalContextType ctx) : m_context(ctx), m_realm(realm) {}
~RealmDelegate() {
remove_all_notifications();
// All protected values need to be unprotected while the context is retained.
m_defaults.clear();
m_constructors.clear();
m_notifications.clear();
}
void add_notification(FunctionType notification) {

View File

@ -32,7 +32,7 @@ class Protected<JSGlobalContextRef> {
Protected(Protected<JSGlobalContextRef> &&other) : m_context(other.m_context) {
other.m_context = nullptr;
}
Protected(JSGlobalContextRef ctx) : m_context(ctx) {
explicit Protected(JSGlobalContextRef ctx) : m_context(ctx) {
JSGlobalContextRetain(m_context);
}
~Protected() {