pan-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pan-devel] Possible progress on the windows port...


From: Charles Kerr
Subject: [Pan-devel] Possible progress on the windows port...
Date: Thu, 16 Jan 2003 15:52:51 -0800
User-agent: Mutt/1.3.20i

The console output from beta 3 looks like Pan is making it to gtk_main(),
where it's blocking forever.  About 20 lines into gtk_main() in gtk 2.2,
this code shows up:

>  if (g_main_loop_is_running (main_loops->data))
>    {
>      GDK_THREADS_LEAVE ();
>      g_main_loop_run (loop);
>      GDK_THREADS_ENTER ();
>      gdk_flush ();
>    }

GDK is the drawing library bundled with GTK.
GDK_THREADS_LEAVE / GDK_THREADS_ENTER is used to unlock/lock the gui
drawing mutex.  mutexes are defined in glib, which uses CriticalSections
on newer versions of Windows, so on the platforms locking up this
more-or-less reads:

>  if (g_main_loop_is_running (main_loops->data))
>    {
>      EnterCriticalSection (gdk_gui_lock);
>      g_main_loop_run (loop);
>      LeaveCriticalSection (gdk_gui_lock);
>      gdk_flush ();
>    }

However, since Pan hasn't entered a critical section yet.
This is a problem, according to msdn:

>  If a thread calls LeaveCriticalSection when it does not have ownership of
>  the specified critical section object, an error occurs that may cause another
>  thread using EnterCriticalSection to wait indefinitely.

Sound familiar?
This sounds very much like what we're seeing in Pan on Windows... :)

And in fact the GTK FAQ is explicit about just this point, that threaded
apps must call gdk_threads_enter() before calling gtk_main()
http://www.gtk.org/faq/#AEN462

>  A minimal main program for a threaded GTK+ application looks like:
>  
>  int
>  main (int argc, char *argv>  [])
>  {
>    GtkWidget *window;
>  
>    g_thread_init(NULL);
>    gtk_init(&argc, &argv);
>  
>    window = create_window();
>    gtk_widget_show(window);
>  
>    gdk_threads_enter();
>    gtk_main();
>    gdk_threads_leave();
>  
>    return(0);
>  }

Though it's been a threaded app for years, Pan's never wrapped gtk_main()
with these.  And it doesn't seem to be a problem except for on Windows. d'oh!

So tonight I'll fire up cygwin/mingw and build a new Windows beta.
I'll also try to finalize the building-pan-on-windows HOWTO.

cheers,
Charles




reply via email to

[Prev in Thread] Current Thread [Next in Thread]