Re: glib ref counting problem



Hi Russel,

Russell Shaw wrote:
Stefan Kost wrote:

hi hi,

hope that someone can enlighten me with my understanding of the gobject
ref-counting regarding to object destruction.

I have a gobject called BtSong. Upon construction it creates instances of
BtPattern, BtSetup and so on where it passes itself along.
Thus each child object now holds a reference to the BtSong object.
When the application that initialy created the BtSong instance is
done, it would
like to destroy the object with all the accosiated ressources. It
therefore
calles g_object_unref(song);.
Now the problem is that this only decreases the ref-count from e.g. 5
to 4,
because the child objects still have their reference on it.
Therefore the dispose() routine is not called and therefore the BtSong
does not
release (unref) its child objects.

Apparently I have not yet understand the gobject system fully :-(
Can anyone tell me how to do it properly?

Do you need BtPattern etc to ref BtSong?
When I receive a reference to an object and I keep this reference localy, I
should ref it.

Unref BtPattern etc in BtSong dispose handler, and in BtPattern etc
dispose handlers, unref BtSong.
I posted a more detailed description to Tristans reply. Hopefully that makes the
deadlocking situation clearer.

Ciao
  Stefan
-- 
      \|/            Stefan Kost
     <@ @>           private            business
+-oOO-(_)-OOo------------------------------------------------------ - - -  -   -
|       __  Address  Simildenstr. 5     HTWK Leipzig, Fb IMN, Postfach 301166
|      ///           04277 Leipzig      04251 Leipzig
| __  ///            Germany            Germany
| \\\///    Phone    +49341 2253538     +49341 30766101
|  \__/     EMail    st_kost_at_gmx.net kost_at_imn.htwk-leipzig.de
|           WWW      www.sonicpulse.de  www.imn.htwk-leipzig.de/~kost/about.html
===-=-=--=---=---------------------------------- - - -  -    -


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]