Re: Gtk2::ImageView memory issue



Jeffrey Ratcliffe wrote:
g_boxed_type_register_static is being called OK, so I guess the
problem is that GBoxedFreeFunc isn't being triggered. But now I am out
of my depth...

Do you have a GdkPixbufDrawCache entry in your 'maps' file? Or do you call gperl_register_boxed for GdkPixbufDrawCache manually? If neither of these, then Glib doesn't know about this type at all, and consequently doesn't set it up to inherit from Glib::Boxed.

You have a custom newSVGdkPixbufDrawCache function declared as 'static', so I guess you just call it manually wherever you need to convert a GdkPixbufDrawCache to an SV. In that case, just free the thing with gdk_pixbuf_draw_cache_free once you're done with it. There's also no point in registered a boxed type when you do it like this.

The alternative is to go GBoxed all the way: register a custom GBoxed type[1] and put an entry for it in your 'maps' file so that converters and typemaps are generated for it[2]. Then register custom wrap and unwrap functions for the new GBoxed type that convert to and from hashes. See the handling of GtkBorder in Gtk2/xs/GtkEntry.xs for an example.

[1] The gdk_pixbuf_draw_cache_get_type you sent registers g_boxed_copy as the GBoxedCopyFunc -- this doesn't work. g_boxed_copy is the generic function used to invoke the GBoxedCopyFunc registered for a type. If the C library doesn't provide a copy function, just write a fake one which simply croaks.

[2] In your header file, make sure the type macro for the custom GBoxed type is defined before you include the generated '-autogen.h' header. The converters defined in it are wrapped inside #ifdefs on the type macro.



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