From: Axel Simon <simona@co...> - 2009-07-23 19:55:33
Mon Jul 20 15:04:41 EDT 2009 Axel.Simon@...
* Fix reference counting for GObjects.
This bug is only present in Glib libraries >2.10 which introduced floating
references. The problem is that even GObjects have always a floating
reference which has to be turned into a permanent reference. So far,
we omitted this call which had the effect that we would keep the object
around with a floating reference. Some objects in Gtk will call ref_sink
on an object that is passed to them, rather than ref. This causes the
floating reference to be turned into a proper one, rather than adding a new
reference. Thus, when the Haskell GC comes along, the object is unref'd and
destroyed while it's still being held in the Gtk object. This patch always
ref_sinks the object, resulting in a proper refence being held by Haskell
and forcing every ref_sink in Gtk code to have the semantics of ref.
hunk ./glib/System/Glib/GObject.chs.pp 142
+ -- change the exisiting floating reference into a proper reference;
+ -- the name is confusing, what the function does is ref,sink,unref
+ objectRefSink objPtr