> > This will actually
> > decrement the ref count on the real palette (making it 2, one for src &
> > dest surfaces).
>
> That is usually the result but the real  story is a bit more complicated.
> The interface object itself is reference counted. The reference count is
> 1 when you create the object. Calling Release() on it will decrement that
> reference count (AddRef() can be used to increase the ref count). When
> the ref count reaches 0 the interface object's destructor is called which
> will drop the reference on the real palette (CorePalette).

So _both_ the interface object and real object are ref counted? Why?

> But normally you don't really have to think about this stuff. Just
> follow the simple rule of calling Release() on all interface objects
> you created when you no longer need them.

But I didn't create an interface class, IDirectFBSurface created the instance 
of the interface class inside GetPalette()?


> > > > If I understand what you're saying it does, but SetPalette will then
> > > > take ownership of it, calling delete when it's destroyed. But I still
> > > > have to call Release on the newly created object to decrement it's
> > > > ref count. Otherwise, when the new surface is destroyed it won't
> > > > delete the palette because it's ref count > 1?
> > >
> > > SetPalette will not touch the interface reference count.
> > > So no taking ownership there.
> >
> > But this sounds to me that I'm also going to end up with the interface
> > object never being deleted. Surely if the dest surface doesn't take
> > ownership of the interface object in SetPalette, I'm responsible for
> > freeing it? So I need to call release and then delete?
>
> There is no delete. Just Release().

Ok... so who deletes the interface object? Presumably the dest surface, which 
takes ownership of the interface object in SetPalette()? Or rather the dest 
surface will increment the interface's ref count and decrement it again when 
the surface is released. If, when it's decremented, the ref count is zero, the 
object will be deleted. Correct?

I guess all I really need to know is that I have to call Release() and I don't 
have to delete it. It just seemed very strange, especially after reading that 
there's a new IDirectFBPalette::CreateCopy() method in the 1.3 API. Oh well, 
thanks for the help.



Cheers,

Tom


_______________________________________________
directfb-users mailing list
directfb-users@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users

Reply via email to