Re: GIcon thoughts
- From: Tim Janik <timj gtk org>
- To: Alexander Larsson <alexl redhat com>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>, Matthias Clasen <mclasen redhat com>
- Subject: Re: GIcon thoughts
- Date: Mon, 14 Jan 2008 10:12:22 +0100 (CET)
On Thu, 10 Jan 2008, Alexander Larsson wrote:
On Wed, 2008-01-09 at 13:53 -0500, Matthias Clasen wrote:
We can't implement the cache using toggle references for 2 reasons:
a) GtkIconSize is a boxed, not an object
b) toggle references only work for a single user, thus they have
to be reserved for bindings, at least bindable objects.
I propose to instead turn GtkIconInfo into a refcounted boxed object,
and then implement the caching logic for the case that the refcount
drops to one.
I'm not sure this is enought, cache-wise. In many cases you'd get a
GtkIconInfo, then get the pixbuf for that, save the pixbuf (e.g. in a
widget) and unref the info. In fact, it seems unlikely that apps would
keep the GtkIconInfo alive for long periods of time. It would be nice if
we could get the GtkIconInfo cached until the last ref is dropped to the
pixbuf.
sounds like you should simply keep a reference count from the pixbuf onto
the corresponding GtkIconInfo. using object data for instance.
Of course, this is slightly harder, as GdkPixbuf is a public GObject
where we can't use toggle references. We could however implement this
with some help from the GdkPixbuf implementation. For instance, if we
add a resurrect signal to GdkPixbuf and have the dispose()
implementation emit this then the cache could connect to this and grab a
ref (for some time) before finalization. (The dispose call must also
detect that the object is ressurected and avoid chaining to dispose.)
you're not free to skip chaining in dispose() implementations (just
like you aren't free to skip chaining in finalize() or anywhere else).
adding a reference count in dispose is enough to "resurrect" an object
though, so just do ref(self); in dispose() but don't forget to chain up.
this'll prevent finalization (finalize() is only called for objects with
ref_count==0).
That might be useful for other pixbuf caches too.
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]