From 61c63a6af9d63f757f9fa591543d13ff3ed5a1de Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 12 Dec 2013 00:10:09 +0800 Subject: [PATCH] Fix crashes about persistent v8 functions. --- common/api/atom_api_id_weak_map.cc | 5 ++--- common/v8/native_type_conversions.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/common/api/atom_api_id_weak_map.cc b/common/api/atom_api_id_weak_map.cc index 75a18fb17c8f..2ee2cf32913c 100644 --- a/common/api/atom_api_id_weak_map.cc +++ b/common/api/atom_api_id_weak_map.cc @@ -63,9 +63,8 @@ void IDWeakMap::Add(const v8::FunctionCallbackInfo& args) { v8::Local v8_value = args[0]->ToObject(); v8_value->SetHiddenValue(v8::String::New("IDWeakMapKey"), ToV8Value(key)); - RefCountedV8Object& value = self->map_[key]; - value->reset(v8_value); - value->MakeWeak(self, WeakCallback); + self->map_[key] = new RefCountedPersistent(v8_value); + self->map_[key]->MakeWeak(self, WeakCallback); args.GetReturnValue().Set(key); } diff --git a/common/v8/native_type_conversions.h b/common/v8/native_type_conversions.h index 8a1e96615cc3..49ad3a6f71a7 100644 --- a/common/v8/native_type_conversions.h +++ b/common/v8/native_type_conversions.h @@ -226,7 +226,7 @@ bool V8ValueCanBeConvertedTo(v8::Handle value) { } template<> inline -bool V8ValueCanBeConvertedTo>( +bool V8ValueCanBeConvertedTo( v8::Handle value) { return value->IsFunction(); }