From: Duncan C. <dun...@wo...> - 2007-06-30 00:40:00
|
Fri Jun 29 17:03:26 PDT 2007 Duncan Coutts <du...@ha...> * Make the check for the GThread system being initialised more robust We previously used an evil top level IORef however in GHCi that does not work because that state gets reverted when we :reload, and so we end up calling g_thread_init again which aborts. So now we have a little C wrapper around the g_thread_supported macro and we use that to check if g_thread_init was already done. hunk ./Makefile.am 21 + gtk/Graphics/UI/Gtk/General/hsgthread.h \ hunk ./Makefile.am 421 + gtk/Graphics/UI/Gtk/General/hsgthread.c \ hunk ./gtk/Graphics/UI/Gtk/General/General.chs 160 -{-# NOINLINE gthreadsInitialisedRef #-} -gthreadsInitialisedRef :: IORef Bool -gthreadsInitialisedRef = unsafePerformIO (newIORef False) - hunk ./gtk/Graphics/UI/Gtk/General/General.chs 161 --- we've got to keep track of whether or not we've called it already, hence --- the ugly top-level IORef trick. Sigh. +-- we've got to keep track of whether or not we've called it already. Sigh. hunk ./gtk/Graphics/UI/Gtk/General/General.chs 165 - gthreadsInitialised <- readIORef gthreadsInitialisedRef + gthreadsInitialised <- liftM (toBool . fromIntegral) gtk2hs_thread_supported hunk ./gtk/Graphics/UI/Gtk/General/General.chs 168 - writeIORef gthreadsInitialisedRef True + +foreign import ccall "hsgthread.h gtk2hs_thread_supported" + gtk2hs_thread_supported :: IO CInt addfile ./gtk/Graphics/UI/Gtk/General/hsgthread.c hunk ./gtk/Graphics/UI/Gtk/General/hsgthread.c 1 +/* Annoyingly, g_thread_supported is actuall a macro so we need this silly + * little wrapper functions. Grrr. */ + +#include <glib/gthread.h> + +int gtk2hs_thread_supported () { + return g_thread_supported(); +} addfile ./gtk/Graphics/UI/Gtk/General/hsgthread.h hunk ./gtk/Graphics/UI/Gtk/General/hsgthread.h 1 +/* g_thread_supported wrapper function */ + +int gtk2hs_thread_supported (); |