Re: Browser crash using <nsCOMPtr> inside plugins !

Alec Flett <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xpcom
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
>   if (scriptablePeer)
>    {
>   // ... told them the browser
>   *(nsISupports **)value = scriptablePeer;

here, you probably want scriptablePeer.get();
also, when assigning to a raw pointer, you're not going to get automatic 
addref'ing - so you have to say

// still need to ADDREF because "value" is not a nsCOMPtr
*(nsISupports**)value = scriptablePeer.get();
NS_ADDREF(*(nsISupports**)value);

my suggestion would be at least to use an intermediary pointer to make 
this readable:

// assign-and-addref is a common pattern
nsISupports* result = scriptablePeer.get();
NS_ADDREF(result);

// now do the funky casting
*(nsISupports**)value = result;

Alec
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.