Re: glib ref counting problem
- From: Stefan Kost <kost imn htwk-leipzig de>
- To: Tristan Van Berkom <vantr touchtunes com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: glib ref counting problem
- Date: Mon, 20 Sep 2004 17:05:53 +0200
Hi Tristan,
Tristan Van Berkom wrote:
Stefan Kost wrote:
[...]
I will try to make it clearer.
application creates the BtSong
BtSong->refct=1
the songs instance init creates the private BtPattern and BtSetup
instances
and passes itself to their constructiors.
BtSong->refct=3
BtPattern->refct=1
BtSetup->refct=1
Why should (G_OBJECT(BtSong)->ref_count > 1) ?
BtPattern & BtSetup do *not* need a reference on BtSong if
BtPattern & BtSetup *belong* to BtSong.
unfortunately there are no explicit docs for the behaviour, but in set_property
method receiving a pointer needs to be secured. I will now try to switch to
add_weak_pointer(). One thing I dont get about this function is why I have to
pass the object and then the pointer to my weak pointer. In practice it will
look like:
myobject=object;
g_object_add_weak_pointer(myobject,&myobject);
Btw.: the docs should say, that the method does not initialize the passed
pointer to point to object.
same for
g_object_remove_weak_pointer();
... I am drifting away ;-)
Anyway, I hope that this is the recommended way of doing these things, as I will
update the GObject tutorial soon.
- App creates (and "owns") BtSong
- BtSong creates (and "owns") BtPattern
- BtSong creates (and "owns") BtSetup
- App unref's BtSong
- BtSong unref's BtPattern
- BtSong unref's BtSetup
Cheers,
-Tristan
--
\|/ 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]