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

Rob Groen robgr at xs4all.nl
Tue Aug 13 22:49:04 CEST 2002


In july I formulated a problem with tasking and GtkAda. To my suprise nobody
responded sofar. If the problem stated below is not reproducable please let
me, because then apparently somthing is wrong with my configuration.

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:
I have a little program, consisting of several tasks. One of these tasks
delays on a timer. When the timer expires that task want to change a
property of a button (in this case the sensitivity). My problem is that as
long as the button that the taks wants to change is not the last button used
by the user all is fine. The task can change the button properties. However,
if the last thing the user does before the timer (in the others taks)
expires is pressing the button the task wants to changen, then 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?? and more given the ZIP file can anyone reproduce the
problem.

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 --------------
A non-text attachment was scrubbed...
Name: Test.zip
Type: application/x-zip-compressed
Size: 4181 bytes
Desc: not available
Url : /pipermail/gtkada/attachments/20020813/58404144/attachment.bin 


More information about the gtkada mailing list