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.
This commit is contained in:
Cheng Zhao 2015-03-23 16:19:55 +08:00
parent 38aba07290
commit 40da835cbb
6 changed files with 5 additions and 6 deletions

View file

@ -176,7 +176,7 @@ class Constructor {
}
base::StringPiece name_;
v8::Persistent<v8::FunctionTemplate> constructor_;
v8::UniquePersistent<v8::FunctionTemplate> constructor_;
DISALLOW_COPY_AND_ASSIGN(Constructor);
};

View file

@ -112,7 +112,7 @@ class Constructor {
}
base::StringPiece name_;
v8::Persistent<v8::FunctionTemplate> constructor_;
v8::UniquePersistent<v8::FunctionTemplate> constructor_;
DISALLOW_COPY_AND_ASSIGN(Constructor);
};

View file

@ -57,7 +57,7 @@ class CallbackHolderBase {
private:
static MATE_WEAK_CALLBACK(WeakCallback, v8::External, CallbackHolderBase);
v8::Persistent<v8::External> v8_ref_;
v8::UniquePersistent<v8::External> v8_ref_;
DISALLOW_COPY_AND_ASSIGN(CallbackHolderBase);
};

View file

@ -60,7 +60,7 @@ class CallbackHolderBase {
private:
static MATE_WEAK_CALLBACK(WeakCallback, v8::External, CallbackHolderBase);
v8::Persistent<v8::External> v8_ref_;
v8::UniquePersistent<v8::External> v8_ref_;
DISALLOW_COPY_AND_ASSIGN(CallbackHolderBase);
};

View file

@ -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;
}

View file

@ -74,7 +74,7 @@ class Wrappable {
private:
static MATE_WEAK_CALLBACK(WeakCallback, v8::Object, Wrappable);
v8::Persistent<v8::Object> wrapper_; // Weak
v8::UniquePersistent<v8::Object> wrapper_; // Weak
DISALLOW_COPY_AND_ASSIGN(Wrappable);
};