@@ -34,6 +34,10 @@ - (instancetype)initWithMap:(std::shared_ptr<Persistent<Value>>)map isolate:(Iso
3434
3535- (id )nextObject {
3636 Isolate* isolate = self->isolate_ ;
37+ v8::Locker locker (isolate);
38+ Isolate::Scope isolate_scope (isolate);
39+ HandleScope handle_scope (isolate);
40+
3741 Local<Context> context = self->cache_ ->GetContext ();
3842 Local<v8::Array> array = self->map_ ->Get (isolate).As <Map>()->AsArray ();
3943
@@ -82,15 +86,23 @@ - (instancetype)initWithProperties:(std::shared_ptr<Persistent<Value>>)dictionar
8286}
8387
8488- (Local<v8::Array>)getProperties {
89+ v8::Locker locker (self->isolate_ );
90+ Isolate::Scope isolate_scope (self->isolate_ );
91+ EscapableHandleScope handle_scope (self->isolate_ );
92+
8593 Local<Context> context = self->cache_ ->GetContext ();
8694 Local<v8::Array> properties;
8795 Local<Object> dictionary = self->dictionary_ ->Get (self->isolate_ ).As <Object>();
8896 tns::Assert (dictionary->GetOwnPropertyNames (context).ToLocal (&properties), self->isolate_ );
89- return properties;
97+ return handle_scope. Escape ( properties) ;
9098}
9199
92100- (id )nextObject {
93101 Isolate* isolate = self->isolate_ ;
102+ v8::Locker locker (isolate);
103+ Isolate::Scope isolate_scope (isolate);
104+ HandleScope handle_scope (isolate);
105+
94106 Local<Context> context = self->cache_ ->GetContext ();
95107 Local<v8::Array> properties = [self getProperties ];
96108 if (self->index_ < properties->Length ()) {
@@ -107,6 +119,10 @@ - (id)nextObject {
107119
108120- (NSArray *)allObjects {
109121 Isolate* isolate = self->isolate_ ;
122+ v8::Locker locker (isolate);
123+ Isolate::Scope isolate_scope (isolate);
124+ HandleScope handle_scope (isolate);
125+
110126 Local<Context> context = self->cache_ ->GetContext ();
111127 NSMutableArray * array = [NSMutableArray array ];
112128 Local<v8::Array> properties = [self getProperties ];
@@ -146,6 +162,10 @@ - (instancetype)initWithJSObject:(Local<Object>)jsObject isolate:(Isolate*)isola
146162}
147163
148164- (NSUInteger )count {
165+ v8::Locker locker (self->isolate_ );
166+ Isolate::Scope isolate_scope (self->isolate_ );
167+ HandleScope handle_scope (self->isolate_ );
168+
149169 Local<Object> obj = self->object_ ->Get (self->isolate_ ).As <Object>();
150170
151171 if (obj->IsMap ()) {
@@ -163,6 +183,10 @@ - (NSUInteger)count {
163183
164184- (id )objectForKey : (id )aKey {
165185 Isolate* isolate = self->isolate_ ;
186+ v8::Locker locker (isolate);
187+ Isolate::Scope isolate_scope (isolate);
188+ HandleScope handle_scope (isolate);
189+
166190 Local<Context> context = self->cache_ ->GetContext ();
167191 Local<Object> obj = self->object_ ->Get (self->isolate_ ).As <Object>();
168192
@@ -194,6 +218,10 @@ - (id)objectForKey:(id)aKey {
194218}
195219
196220- (NSEnumerator *)keyEnumerator {
221+ v8::Locker locker (self->isolate_ );
222+ Isolate::Scope isolate_scope (self->isolate_ );
223+ HandleScope handle_scope (self->isolate_ );
224+
197225 Local<Value> obj = self->object_ ->Get (self->isolate_ );
198226
199227 if (obj->IsMap ()) {
0 commit comments