All, > [Original message to gtk2hs-users] > > I have been repeatedly beaten by accelerators in the last two weeks > and tried to dig this bug myself with no success. The problem is my > accelerators start working but after being used for some time they > just wear off and stop working
I've finally managed to isolate and fix this bug after some more debugging. It was an issue with glib's reference counting. The action group's reference counter was dropping to zero and it was getting finalized somehow after some number of action activations. When it was finalized it took the actions and accelerator with it, thus everything stopped working. I changed the action group creation code to use makeNewGObject instead of constructNewGObject, since it includes reference incrementing, and everything now works. There's patch available at my personal repo at http://thiagoarrais.com/repos/gtk2hs-upstream/. This patch fixes this issue, but I'm not sure it is the right way to do it. I may have introduced a memory leak without noticing. Maybe instead of incrementing the counter here we should stop decrementing it somewhere else... I have also noticed that other non-GtkObject objects get initialized using constructNewGObject while the Object module doesn't even provide something similar to constructNewGObject. The comment for constructNewGObject states that newly created GObjects already have a reference count of one, therefore they don't need to be reference counted. This seems weird at first glance. Given that GtkObject inherits from GObject it should also have a reference count of one upon creation, shouldn't it? Even so, Gtk2Hs does increment the reference counter for every GtkObject created. Why not every time that a GObject is created? Should Gtk2Hs get rid of constructNewGObject and use makeNewObject everywhere? Cheers, Thiago Arrais ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge _______________________________________________ Gtk2hs-devel mailing list Gtk2hs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel