Permalink
Browse files

weakref: save the weakref proxy instance as a Local ref

  • Loading branch information...
1 parent 7784f3f commit 75df705108c8091b633e7c69884428900b8a396c @TooTallNate committed Nov 17, 2013
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/weakref.cc
View
@@ -166,15 +166,16 @@ NAN_METHOD(Create) {
proxy_container *cont = (proxy_container *)
malloc(sizeof(proxy_container));
- NanAssignPersistent(Object, cont->proxy, NanPersistentToLocal(proxyClass)->NewInstance());
+ Local<Object> proxy = NanPersistentToLocal(proxyClass)->NewInstance();
+ NanAssignPersistent(Object, cont->proxy, proxy);
NanAssignPersistent(Object, cont->target, args[0]->ToObject());
NanAssignPersistent(Object, cont->emitter, args[1]->ToObject());
NanSetInternalFieldPointer(NanPersistentToLocal(cont->proxy), 0, cont);
NanMakeWeak(cont->target, reinterpret_cast<void *>(cont), TargetCallback);
- NanReturnValue(NanPersistentToLocal(cont->proxy));
+ NanReturnValue(proxy);
}
/**

0 comments on commit 75df705

Please sign in to comment.