Re: Releasing IGraphBuilder



GREAT, was just that AddRef I forget... dumb...

Tx, :)

I'm going to have a look to that CComPtr...

Tx again for that stupid error,

Nicolas,

"Thore Karlsen [MVP DX]" <sid@xxxxxxxx> wrote in message
news:25p7k118f6vbfa69srvmffkp9o2u08cvbk@xxxxxxxxxx
> On Wed, 5 Oct 2005 16:25:21 +0200, "Nicolas Bernard"
> <nicolas.bernard@xxxxxxxxxxxxxx> wrote:
>
> [...]
>
>>After thinking a little, I ask myself, IGraphBuilder built the graph
>>determining himself which filter to add. By releasing IGraphBuilder, it
>>must
>>then release all of them, so does it not release mine too ?
>
> The basic rule is: Any interface that you have gotten, you need to
> release. IGraphBuilder may hold other references to the same objects,
> but it won't release your references for you.
>
>>So when I try to release my own CTextureRenderer, IGraphBuilder should
>>have
>>already release it, making a pointer error.
>>Possible ?
>
> After looking at your code again, I see that you're allocating your
> CTextureRenderer with new, but you're not calling AddRef() on it. That
> is a problem. Try this:
>
> m_cTextureRenderer = new CTextureRenderer( NULL, &hr );
> m_cTextureRenderer->AddRef();

> Be careful not to explicitly delete m_cTextureRenderer using "delete".
> Since it's used a COM object, the last Release() will delete the object.
>
>>therefor, I think more and more of using thos CComPtr... But I don't like
>>to
>>have so much abstraction.......
>
> It's not really abstraction, you're not really hiding anything. It's
> just a very useful tool to make sure you don't shoot yourself in the
> foot. :) It makes your code much simpler and easier to read, and that's
> a good thing.
>
> --
> New to newsgroups? Read: http://dev.6581.com/newsgroups.html


.