Upstream good ideas from Muon

This commit is contained in:
Matt Crocker 2017-10-23 22:38:55 -07:00
parent ca8f45a501
commit c5914516c8
2 changed files with 9 additions and 3 deletions

View file

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

View file

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