On Sun, 2008-02-10 at 09:29 -0500, Kevin Wright wrote: > Emmanuele Bassi wrote: > >> > >> explosion=g_new0(ClutterActor,1); > >> > > > > eek, what is this? you don't need to allocate a ClutterActor with > > g_new0(). > > > > > > No, I probably didn't 'need' to, but it did seem to make any difference > whether I did or didn't use g_new0 with a texture. It crashes.
sure, because you overwrite the pointer just after. you're "just" leaking memory. > Besides, if I wanted to have more than one of my explosions could I not > use g_new0? unless you want to allocate an array of items, but in that case using g_new0 will not do what you think it does. > And then what happens if I want to get rid of them? I > usually use malloc but have been playing with g_new0 as I have seen > others use it elsewhere. those are mistakes, ore you're probably not reading them correctly. clutter_texture_new() will allocate the correct space for you and return a pointer to the actor; it returns ClutterActor* because a ClutterTexture satisfies the ISA relationship, but the allocated space is enough to contain a ClutterTexture, not just a ClutterActor. > > and why are you destroying the texture? unless you want to remove it > > from the container, which should really be done with > > clutter_container_remove() anyway. > > > > I'm destroying it because I want it gone for good -- it served a purpose > and now I no longer need it. If I only remove it would it still be > lingering in the background somewhere? no: since it's refcounted as soon as it is removed from the parent container it will be destroyed as well. in any case, destroying a texture should not segfault; it used to if you had an ATI card and fglrx, which falsely advertised the ability to read the pixels back and segafaulted inside the drivers. this has been fixed (destroying textures will not cause reading the pixels back) in SVN. ciao, Emmanuele. -- Emmanuele Bassi, OpenedHand Ltd. Unit R, Homesdale Business Centre 216-218 Homesdale Rd., Bromley - BR12QZ http://www.o-hand.com -- To unsubscribe send a mail to [EMAIL PROTECTED]
