menuitems and threads bug?

Let me preface this by saying that I have just started using GTK recently,
and I may be doing something completely stupid here (but I don't think I
am). If that is the case, flame away :-)

I am trying to write a threaded program, using GTK 1.2.0 on Solaris 2.6,
using menus. The problem that I observe is that clicking on a menu causes
the program to hang. For instance, I simply added a call to
g_thread_init(NULL); to the example menu program in the tutorial, and
observed this problem.

Stack Trace: [argument addresses removed for readability; sorry i dont
              have a debug libgtk handy]
  [1] ___lwp_mutex_lock()
  [2] _mutex_lwp_lock()
  [3] _cmutex_lock()
  [4] pthread_mutex_lock()
  [5] gtk_menu_item_select_timeout(), line 633 in "gtkmenuitem.c"
  [6] gtk_real_menu_item_select(), line 444 in "gtkmenuitem.c"
  [7] gtk_signal_real_emit()
  [8] gtk_signal_emit()
  [9] gtk_menu_shell_button_press()
  [10] gtk_marshal_BOOL__POINTER()
  [11] gtk_signal_real_emit()
  [12] gtk_signal_emit()
  [13] gtk_widget_event()
  [14] gtk_propagate_event()
  [15] gtk_main_do_event()
  [16] gdk_event_dispatch()
  [17] g_main_dispatch()
  [18] g_main_iterate()
  [19] g_main_run()
  [20] gtk_main()
=>[21] main(argc = 1, argv = 0xeffff7cc), line 111 in "test.c"

what seems to be happening is that gtk_real_menu_item_select is calling
gtk_menu_item_select_timeout directly. However, gtk_real_menu_item_select
is running from the main loop, with the gdk mutex locked, and the timeout
function expects to be called without the mutex locked, and hence it locks

As I said I have just begun using GTK, so please point out any flaws in my
logic or understanding of how things work.

I patched gtkmenuitem.c with the following patch, which solved my problem:

*** gtkmenuitem.c       Wed Feb 24 05:15:10 1999
--- /ltmp/syslaba/mahrens/gtk+-1.2.0/gtk/gtkmenuitem.c  Wed Mar 10 17:39:46 1999
*** 553,556 ****
!       else
        gtk_menu_item_select_timeout (menu_item);
        if(event) gdk_event_free(event);
--- 553,559 ----
!       else {
        gtk_menu_item_select_timeout (menu_item);
+       }
        if(event) gdk_event_free(event);

=======PATCH END=========


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