From: Michal P. <al...@v-...> - 2005-07-23 10:09:32
|
Thanks a lot! I would have had less trouble if I used GHC 6.4, maybe it's time to switch. I have one more question: Is it possible to create a callback that disconnects itself? I can't do it in a straightforward way because the callback can't use the handle that is returned from the callback setting function: con <- onClicked button ({- can't use con here -}) I would be able to use IORef, but I want to keep the amount of global state minimal. Or maybe disconnecting callbacks is a bad practice and I'm missing some design pattern here? By the way, why do you use CVS instead of Darcs used by most Haskell-oriented projects? Regrads, Michal On Sat, 2005-07-23 at 02:11 +0100, Duncan Coutts wrote: > On Thu, 2005-07-21 at 13:53 +0200, Michal Palka wrote: > > Hello, > > > > My last email probably didn't make it to the list, I'm resending it. > > Actually it did but we were probably all on holiday! :-) > > > When I run the following program it crashes with a segmentation fault. > > It runs fine when I remove the line with 'disconnect con'. The machine > > is i386, I'm using GHC 6.2.2 and gtk2hs 0.9.8. > > > > Is using disconnect the correct way of removing callbacks? > > You know I've never actually written a program that uses it! But yes it > is supposed to be the right thing. > > On GHC 6.4 instead of segfaulting it reports: > a.out: schedule: re-entered unsafely. > Perhaps a 'foreign import unsafe' should be 'safe'? > > Which is almost certainly a correct diagnosis of the problem. In other > words it's our fault! :-) > > When I change the disconnect function to be a safe foreign call your > example prog does indeed work. > > I have to say I find that very confusing since I can't see what Haskell > code is being called when we call disconnect. I've had a similar report > about timeoutRemove/idleRemove where it's also not clear that there > should be any callback into Haskell land. > > Anyway, it's fixed in cvs and will be included in the 0.9.8.1 bugfix > release. > > I just wish I understood what was going on here! :-) > > Duncan > |