Re: Class-Scope Properties
- From: Tim Janik <timj gtk org>
- To: Eric Lemings <eric b lemings lmco com>
- Cc: Havoc Pennington <hp redhat com>, Gtk+ Application MList <gtk-app-devel-list gnome org>
- Subject: Re: Class-Scope Properties
- Date: Thu, 20 Sep 2001 15:14:46 +0200 (CEST)
On Thu, 20 Sep 2001, Eric Lemings wrote:
Havoc Pennington wrote:
Anyway, GLib has no way to run stuff at exit, short of atexit(). You
could always install your own atexit() handler to free things, I
guess.
That's a bit of a hack but I suppose it'll work. Thanks.
nah, you don't need atecit() in your case, as far as i understand.
the reason class finalizers are bound to plugin types only is that
only those classes will ever get destructed.
but for your case, you probably only need the B instance as long
as you have 1 or more A instances, right?
so you'd actually do:
AClass {
[...]
B *b;
guint b_count;
};
A_init (A *a)
{
AClass *class = A_GET_CLASS (a);
if (!class->b_count++)
class->b = g_object_new (TYPE_B, NULL);
}
A_finalize (A *a)
{
AClass *class = A_GET_CLASS (a);
if (!--class->b_count)
{
g_object_unref (class->b);
class->b = NULL;
}
/* chain parent */
[...]
}
Eric.
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]