Thank you for your help Boris,
I decided not to go the nsWeakPtr route. I guess i don't understand
XPCOM enough yet.
Instead i'm using nsCOMPtr's and break any circular references by hand.

Gr. Dennis


Boris Zbarsky wrote:
> djorz wrote:
> > I'm trying to implement nsWeakPtr as a member variable of my class.
>
> OK.
>
> > A snippet is located here: http://pastebin.mozilla.org/457 (23 lines of
> > c++)
>
> The GetMyNode looks fine (though I'd null-check mMyNode and then use
> CallQueryReferent, and skip the manual refcounting.
>
> SetMyNode is also OK, though I'd use do_GetWeakReference instead of the
> deprecated NS_GetWeakReference.
>
> But all this only works if aMyNode implements nsISupportsWeakReference.  DOM
> nodes generally don't.
>
> > PS. In my sample it should be "public nsSupportsWeakReference" where it
> > says "public nsISupportsWeakReference"
>
> I'm not even sure why that's there... You don't need that to have an nsWeakPtr
> member; you need that if you want someone else to hold an nsWeakPtr to your
> component.
> 
> -Boris

_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to