[Haskell-cafe] GUI Program Hangs in GHCI
Jason Dagit
dagitj at gmail.com
Mon Jul 4 03:57:10 CEST 2011
On Sun, Jul 3, 2011 at 5:16 PM, Jason Dagit <dagitj at gmail.com> wrote:
> Hello,
>
> I have a GUI program that when I compile it and run it there are no
> problems. When I load it into GHCI and type, "main", it loads the
> main window but there are no window decorations and the program hangs
> to the point where I have to kill the ghci process. You see a
> spinning cursor when you mouse over the window.
>
> I found this old email regarding gtk2hs:
> http://web.archiveorange.com/archive/v/nDNOvMeDATtTGn026lbI
>
> I recompiled the program to use -threaded but the behavior is
> unchanged (if the email above describes my problem then I expected the
> compiled version to start having issues).
On second though, I think this *IS* a threading issue. Depending on
where I add either forkIO or forkOS in main the compiled program
either behaves the same as it does in ghci or it segfaults.
I don't know how to fix it, but I suspect that I have to do something
like what is described here:
http://www.cocoabuilder.com/archive/cocoa/292830-nstimer-not-working-in-multithreaded-application.html
I think the issue is that when I run the GUI code one a thread that
isn't the original thread then I need to explicitly call that threads
run loop. The above link points at this bit of documentation and I
probably need to read it to develop a better understanding:
http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/Multithreading/CreatingThreads/CreatingThreads.html
Jason
More information about the Haskell-Cafe
mailing list