Merge pull request #10889 from electron/avoid-eventemitter-crashes

Avoid EventEmitter crashes
This commit is contained in:
John Kleinschmidt 2017-10-27 11:39:49 -04:00 committed by GitHub
commit b429dafa38
5 changed files with 12 additions and 5 deletions

View file

@ -169,10 +169,10 @@ void Notification::NotificationDisplayed() {
}
void Notification::NotificationDestroyed() {
Emit("close");
}
void Notification::NotificationClosed() {
Emit("close");
}
// Showing notifications

View file

@ -79,8 +79,12 @@ class EventEmitter : public Wrappable<T> {
const Args&... args) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
v8::Local<v8::Object> wrapper = GetWrapper();
if (wrapper.IsEmpty()) {
return false;
}
v8::Local<v8::Object> event = internal::CreateJSEvent(
isolate(), GetWrapper(), sender, message);
isolate(), wrapper, sender, message);
return EmitWithEvent(name, event, args...);
}

View file

@ -62,7 +62,10 @@ class TrackableObject : public TrackableObjectBase,
public:
// Mark the JS object as destroyed.
void MarkDestroyed() {
Wrappable<T>::GetWrapper()->SetAlignedPointerInInternalField(0, nullptr);
v8::Local<v8::Object> wrapper = Wrappable<T>::GetWrapper();
if (!wrapper.IsEmpty()) {
wrapper->SetAlignedPointerInInternalField(0, nullptr);
}
}
bool IsDestroyed() {

View file

@ -74,7 +74,7 @@ Returns:
Emitted when the notification is closed by manual intervention from the user.
This event is not guarunteed to be emitted in all cases where the notification
This event is not guaranteed to be emitted in all cases where the notification
is closed.
#### Event: 'reply' _macOS_

2
vendor/native_mate vendored

@ -1 +1 @@
Subproject commit f047bb61bbd985079dd93e7ed322999550efed1d
Subproject commit bf92fa88b735b8c9ff951e6ef78a531bd10e8778