Re: Gtk2::ImageView memory issue
- From: muppet <scott asofyet org>
- To: "gtk-perl-list gnome org List" <gtk-perl-list gnome org>
- Subject: Re: Gtk2::ImageView memory issue
- Date: Fri, 6 Mar 2009 21:28:19 -0500
On Mar 6, 2009, at 5:40 PM, Jeffrey Ratcliffe wrote:
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?
No. _own is for when your perl wrapper will hold onto the actual
boxed object. This is what the default wrappers do. You are
converting the boxed object from a C struct to a native perl object
(the hash) and back, so you don't need to hold on to the C object,
therefore, you don't need _own.
How can I test that the _free method is being called?
Simplest is to wrap it:
static void
wrap_gdk_pixbuf_draw_cache_free (void * the_thing)
{
g_print ("OMG I'M ABOUT TO FREE A GdkPixbufDrawCache AT %p\n",
the_thing);
gdk_pixbuf_draw_cache_free (the_thing);
}
Then register wrap_gdk_pixbuf_draw_cache_free () as the destroy
function instead of gdk_pixbuf_draw_cache_free() and watch for the
messages on stdout.
--
The one difference between Dali and a crazy man is very simple: Dali
is not crazy at all.
-- Salvador Dali
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]