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
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_