If you have a Handle which is known to be persistent you should use the
Persistent::Cast to cast it to a Persistent handle and then call ClearWeak.

  Persistent::Cast(some_handle_whish_is_known_to_be_persistent).ClearWeak();

If you use Persistent::New a new persistent handle will be created pointing
to the same object and the existing one with the weak callback registered
will still be in existence causing the callback to be called.

Regards,
Søren

On Tue, Dec 1, 2009 at 05:24, Abdulla Kamar <[email protected]> wrote:

> Oh no, that's the exact behaviour I want, I want to transfer the ownership
> back to C++. But in my experiments, if I construct a Persistent from a
> Handle, calling ClearWeak() has no effect and the weak reference callback is
> still called.
>
>
> On Tue, Dec 1, 2009 at 1:47 PM, Stephan Beal <[email protected]>wrote:
>
>> On Tue, Dec 1, 2009 at 3:23 AM, Abdulla <[email protected]> wrote:
>>
>>> If I'm passed a Handle<> that I know is a Persistent<>, can I
>>> construct the persistent from the handle and call ClearWeak()? That
>>> doesn't seem to be working for me.
>>>
>>
>> Are you sure you want ClearWeak()? That will, if i'm not mistaken, tell v8
>> that the handle is no longer persistent, but _will_not_ (in my experiments)
>> trigger the weak callback. It is for use when your objects need to be
>> destroyed from outside v8, so that you can tell v8 not to call the dtor. At
>> least, that's how i use it.
>>
>> i think what you're looking for is Dispose().
>>
>> --
>> ----- stephan beal
>> http://wanderinghorse.net/home/stephan/
>>
>>  --
>> v8-users mailing list
>> [email protected]
>> http://groups.google.com/group/v8-users
>>
>
>
>
> --
> Thank you
> Abdulla
>
>  --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
>

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to