fix: crash on exit in Event destructor (#26537)
This commit is contained in:
parent
b894151745
commit
9d54fdfd12
1 changed files with 10 additions and 6 deletions
|
@ -21,11 +21,15 @@ Event::Event() {}
|
||||||
Event::~Event() {
|
Event::~Event() {
|
||||||
if (callback_) {
|
if (callback_) {
|
||||||
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
|
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
|
||||||
v8::HandleScope scope(isolate);
|
// If there's no current context, it means we're shutting down, so we don't
|
||||||
auto message = gin::DataObjectBuilder(isolate)
|
// need to send an event.
|
||||||
.Set("error", "reply was never sent")
|
if (!isolate->GetCurrentContext().IsEmpty()) {
|
||||||
.Build();
|
v8::HandleScope scope(isolate);
|
||||||
SendReply(isolate, message);
|
auto message = gin::DataObjectBuilder(isolate)
|
||||||
|
.Set("error", "reply was never sent")
|
||||||
|
.Build();
|
||||||
|
SendReply(isolate, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +66,7 @@ gin::ObjectTemplateBuilder Event::GetObjectTemplateBuilder(
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Event::GetTypeName() {
|
const char* Event::GetTypeName() {
|
||||||
return "WebRequest";
|
return "Event";
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
Loading…
Add table
Reference in a new issue