fix: enter handle scope when creating custom event (#22657)

This commit is contained in:
Cheng Zhao 2020-03-16 14:20:32 +09:00 committed by GitHub
parent 18c74a11f4
commit 7814c67830
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,6 +62,8 @@ class EventEmitter : public gin_helper::Wrappable<T> {
// this.emit(name, new Event(flags), args...);
template <typename... Args>
bool EmitWithFlags(base::StringPiece name, int flags, Args&&... args) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
return EmitCustomEvent(name,
internal::CreateEventFromFlags(isolate(), flags),
std::forward<Args>(args)...);
@ -108,8 +110,6 @@ class EventEmitter : public gin_helper::Wrappable<T> {
// It's possible that |this| will be deleted by EmitEvent, so save anything
// we need from |this| before calling EmitEvent.
auto* isolate = this->isolate();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
auto context = isolate->GetCurrentContext();
gin_helper::EmitEvent(isolate, GetWrapper(), name, event,
std::forward<Args>(args)...);