Fix crashes about persistent v8 functions.

This commit is contained in:
Cheng Zhao 2013-12-12 00:10:09 +08:00
parent e4bfa373de
commit 61c63a6af9
2 changed files with 3 additions and 4 deletions

View file

@ -63,9 +63,8 @@ void IDWeakMap::Add(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Local<v8::Object> v8_value = args[0]->ToObject(); v8::Local<v8::Object> v8_value = args[0]->ToObject();
v8_value->SetHiddenValue(v8::String::New("IDWeakMapKey"), ToV8Value(key)); v8_value->SetHiddenValue(v8::String::New("IDWeakMapKey"), ToV8Value(key));
RefCountedV8Object& value = self->map_[key]; self->map_[key] = new RefCountedPersistent<v8::Object>(v8_value);
value->reset(v8_value); self->map_[key]->MakeWeak(self, WeakCallback);
value->MakeWeak(self, WeakCallback);
args.GetReturnValue().Set(key); args.GetReturnValue().Set(key);
} }

View file

@ -226,7 +226,7 @@ bool V8ValueCanBeConvertedTo<atom::NativeWindow*>(v8::Handle<v8::Value> value) {
} }
template<> inline template<> inline
bool V8ValueCanBeConvertedTo<v8::Persistent<v8::Function>>( bool V8ValueCanBeConvertedTo<atom::RefCountedV8Function>(
v8::Handle<v8::Value> value) { v8::Handle<v8::Value> value) {
return value->IsFunction(); return value->IsFunction();
} }