[gtkada] Deadlocks when using Ada tasking and GtkAda on WindowsNT

Rob Groen robgr at xs4all.nl
Wed Jul 3 20:59:31 CEST 2002


I have a problem using Ada task and GtkAda on WindowsNT 4.0 SP6. I'm using Glade 0.5.9 and Gtkada 1.3.12, the Win32 port.

The problem is this:
When a task (not the main task) wants to modify a button, and that button is the last one used the program deadlocks. Callbacks on the button are defined in the 'main' program. The Gdk.Threads package is used. A sample program is below. The whole program, including the glade file is in the attached ZIP file.

What am i doing wrong?? One thing I found out is that when you change the button outside the thread.enter-thread.leave pair all seems to be going all right. However, in the real program this lead to all sorts of acces violations and other errors.

with Gtk; use Gtk;
with Gtk.Main;
with Gtk.Widget; use Gtk.Widget;
with gdk.threads;
with gtk.label; use gtk.label;
with gtk.button; use gtk.button;
with Window_Pkg; use Window_Pkg;

procedure Test is

   task t is
      entry stop;
   end t;
   task body t is
      sens : boolean := true;
   begin
      loop
         select
            accept stop;
            exit;
         or
            delay 5.0;
            sens := not sens;
            gdk.threads.enter;
            if sens then
               set_text (
                  gtk_label (get_child (window.button3)),
                  "SENSITIVE");
            else
               set_text (
                  gtk_label (get_child (window.button3)),
                  "NOT SENSITIVE");
            end if;
            set_sensitive (window.button3, sens);
            gdk.threads.leave;
         end select;
      end loop;
   end t;
begin
   Gdk.Threads.Init;
   Gtk.Main.Set_Locale;
   Gtk.Main.Init;
   Gtk_New (Window);
   Set_Text (
      Window.Label,
      "Buttons 2 & 3 increment a counter and display its value in the button" & ascii.lf &
      "Furthermore, a task changes the sensitivity of the right button ever 5 secs" & ascii.lf &
      "When the right button is the last one clicked before a sensitivity change" & ascii.lf &
      "the program deadlocks when a sensitivity change is attempted by the task." & ascii.lf &
      "If however the last button clicked is the middle button, then all goes well" & ascii.lf &
      ascii.lf &
      "How come???");
   Show_All (Window);
   Gdk.Threads.Enter;
   Gtk.Main.Main;
   Gdk.Threads.Leave;
   T.Stop;
end Test;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/gtkada/attachments/20020703/dab282de/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test.zip
Type: application/x-zip-compressed
Size: 4181 bytes
Desc: not available
Url : /pipermail/gtkada/attachments/20020703/dab282de/attachment.bin 


More information about the gtkada mailing list