Re: Gtk2::ImageView memory issue



2009/3/6 Torsten Schoenfeld <kaffeetisch gmx de>:
GBoxed descendants have their own memory management infrastructure and thus
also their own typemap variants: for functions returning newly constructed
instances of GBoxed descendants, use the _own typemap variant. ÂThen,

I've had to write code to convert the GBox struct to a hash and back
again - e.g.

static SV *
newSVGdkPixbufDrawCache (GdkPixbufDrawCache * cache)
{
  HV * hv = newHV();
  hv_store (hv, "last_pixbuf", 11, newSVGdkPixbuf (cache->last_pixbuf), 0);
  hv_store (hv, "old", 3, newSVGdkPixbufDrawOpts (&cache->old), 0);
  hv_store (hv, "check_size", 10, newSViv (cache->check_size), 0);
  return newRV_noinc ((SV *) hv);
}

Is the _own variant useful here?

Glib::Boxed::DESTROY will call the free function registered for the GBoxed
descendant. Â(Perl packages representing GBoxed descendants are
automatically set up to inherit from Glib::Boxed.)

So I should set up the type to call the _free method as follows:

GType
gdk_pixbuf_draw_cache_get_type(void) {
    static GType t = 0;
    if (!t) {
        t = g_boxed_type_register_static("GdkPixbufDrawCache",
                                         (GBoxedCopyFunc) g_boxed_copy,
                                         (GBoxedFreeFunc)
gdk_pixbuf_draw_cache_free);
    }
    return t;
}

?

How can I test that the _free method is being called?

Regards

Jeff



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