[gtkada] What's exactly happening in Gtk.Main.Init?

Michael Bode michael.bode at laserline.de
Thu Feb 10 19:38:33 CET 2005


I have a really strange problem. I'm writing a GtkAda program on Windows 
XP (Gnat 3.15p, GtkAda 2.2). This program controlls a USB device (a 
spectrometer). I'm talking to this device via some vendor supplied DLL 
for which I've wrote a thin binding to Ada. The device has to be 
initialized and I have to read some parameters from this device. This is 
done in:

package Worker is
    procedure Init_Spectrometer;  -- exported only for debugging.
    task Do_Measure is
      entry Init;     -- this calls Init_Spectrometer;
   end Do_Measure;

end Worker;

This all works fine so far. Now comes the funny part.

with Gtk.Main, Gdk.Threads;
with Worker;
procedure Spec_Server is     -- this is the main program
begin
   Gdk.Threads.G_Init;
   Gdk.Threads.Init;

   Worker.Init_Spectrometer;  -- main task  / works
   Worker.Init_Spectrometer;  -- main task called again / works
   Worker.Do_Measure.Init;    -- entry in 2nd task  / works
   delay 5.0;                             -- let Do_Measure do its job
   Gtk.Main.Init;
   Worker.Init_Spectrometer;  -- main task / doesn't work
    ...
As long as I call Init_Spectrometer *before* Gtk.Main.Init it works. 
Doesn't matter how often or if it is from the main task or my 2nd task. 
But after a call to Gtk.Main.Init the Init_Spectrometer fails. Now, 
Init_Spectrometer doesn't know anything about Gtk. And it fails in a way 
that the device "driver" (which is a DLL and doesn't know anything about 
Ada) simply tells me in plain english there is no data in the device 
(calls give OK return codes, data reads "NOT SET" (C string)). The 
device "driver" DLL may itself  be multithreaded, the docs aren't very 
clear on this.

Any Idea?

-- 
Michael Bode
Laserline GmbH
Fraunhoferstr.
56218 Mülheim-Kärlich
Phone:     +49 2630 964-2200
Fax:       +49 2630 964-2209




More information about the gtkada mailing list