From 40da835cbb7a5f76aacebf9d3ee4b66a62cece71 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Mar 2015 16:19:55 +0800 Subject: [PATCH] Don't reset handle before Wrappable is destroyed It is possible that the user wants to use the V8 object in the destructor. Fixes atom/atom-shell#1112. --- native_mate/constructor.h | 2 +- native_mate/constructor.h.pump | 2 +- native_mate/function_template.h | 2 +- native_mate/function_template.h.pump | 2 +- native_mate/wrappable.cc | 1 - native_mate/wrappable.h | 2 +- 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/native_mate/constructor.h b/native_mate/constructor.h index 1b6a23c14cdc..14ea119e56a9 100644 --- a/native_mate/constructor.h +++ b/native_mate/constructor.h @@ -176,7 +176,7 @@ class Constructor { } base::StringPiece name_; - v8::Persistent constructor_; + v8::UniquePersistent constructor_; DISALLOW_COPY_AND_ASSIGN(Constructor); }; diff --git a/native_mate/constructor.h.pump b/native_mate/constructor.h.pump index 87d10bbc68ee..94a56d424a94 100644 --- a/native_mate/constructor.h.pump +++ b/native_mate/constructor.h.pump @@ -112,7 +112,7 @@ class Constructor { } base::StringPiece name_; - v8::Persistent constructor_; + v8::UniquePersistent constructor_; DISALLOW_COPY_AND_ASSIGN(Constructor); }; diff --git a/native_mate/function_template.h b/native_mate/function_template.h index 54b71c04f886..14ed170080bf 100644 --- a/native_mate/function_template.h +++ b/native_mate/function_template.h @@ -57,7 +57,7 @@ class CallbackHolderBase { private: static MATE_WEAK_CALLBACK(WeakCallback, v8::External, CallbackHolderBase); - v8::Persistent v8_ref_; + v8::UniquePersistent v8_ref_; DISALLOW_COPY_AND_ASSIGN(CallbackHolderBase); }; diff --git a/native_mate/function_template.h.pump b/native_mate/function_template.h.pump index ddfe29a25d11..c3009f2a8288 100644 --- a/native_mate/function_template.h.pump +++ b/native_mate/function_template.h.pump @@ -60,7 +60,7 @@ class CallbackHolderBase { private: static MATE_WEAK_CALLBACK(WeakCallback, v8::External, CallbackHolderBase); - v8::Persistent v8_ref_; + v8::UniquePersistent v8_ref_; DISALLOW_COPY_AND_ASSIGN(CallbackHolderBase); }; diff --git a/native_mate/wrappable.cc b/native_mate/wrappable.cc index 4596d154bdb4..070c3c59d92c 100644 --- a/native_mate/wrappable.cc +++ b/native_mate/wrappable.cc @@ -46,7 +46,6 @@ ObjectTemplateBuilder Wrappable::GetObjectTemplateBuilder( // static MATE_WEAK_CALLBACK(Wrappable::WeakCallback, v8::Object, Wrappable) { MATE_WEAK_CALLBACK_INIT(Wrappable); - MATE_PERSISTENT_RESET(self->wrapper_); delete self; } diff --git a/native_mate/wrappable.h b/native_mate/wrappable.h index 6031674c06b8..f93bf6b3b248 100644 --- a/native_mate/wrappable.h +++ b/native_mate/wrappable.h @@ -74,7 +74,7 @@ class Wrappable { private: static MATE_WEAK_CALLBACK(WeakCallback, v8::Object, Wrappable); - v8::Persistent wrapper_; // Weak + v8::UniquePersistent wrapper_; // Weak DISALLOW_COPY_AND_ASSIGN(Wrappable); };