On Mon, Nov 12, 2018 at 10:47 AM Gautham B A <gautham.bangal...@gmail.com> wrote: > Hi all, > > From the v8 docs, we know that whenever a v8::Local variable needs to live > beyond the function where it was created, we need to escape it with a > v8::EscapableHandleScope. Should I call Escape() when I'm setting a v8::Local > variable as a property of some other v8::Local<v8::Object>? Please see the > code below - > > void GetNewObject(v8::Isolate *isolate) { > v8::HandleScope handle_scope(isolate); > > v8::Local<v8::Object> obj = v8::Object::New(isolate); > SetSomeValue(isolate, obj); > } > > void SetSomeValue(v8::Isolate *isolate, v8::Local<v8::Object> &obj_out){ > v8::EscapableHandleScope handle_scope(isolate); > v8::Local<v8::String> value = v8::String::NewFromUtf8(isolate_, "some_value", > v8::String::kNormalString); > obj_out->Set(1, handle_scope.Escape(value)); // Is it necessary to escape > "value"? > } > > Thanks, > --Gautham
There's no need. It's transitively kept alive by the object you assign it to. If you created a new object and return that, that's when you'd use an EscapableHandleScope. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.