comp.lang.ada
 help / color / mirror / Atom feed
* Access check failed
@ 2004-01-03 14:03 gilmour
  2004-01-03 18:51 ` Stephen Leake
  0 siblings, 1 reply; 5+ messages in thread
From: gilmour @ 2004-01-03 14:03 UTC (permalink / raw)


Why when I press 'Insert' button, following error appears?
"CONSTRAINT_ERROR: win_new_employee_pkg.ads:25 access check failed"
I'am using GtkAda-2.2.0


--package Win_New_Employee_Pkg.Callbacks

with Gtk.Arguments;
with Gtk.Widget; use Gtk.Widget;

package Win_New_Employee_Pkg.Callbacks is
   procedure On_Btninsert_Pressed
     (Object : access Gtk_Button_Record'Class);

end Win_New_Employee_Pkg.Callbacks;


--package body Win_New_Employee_Pkg.Callbacks

with System; use System;
with Glib; use Glib;
with Gdk.Event; use Gdk.Event;
with Gdk.Types; use Gdk.Types;
with Gtk.Accel_Group; use Gtk.Accel_Group;
with Gtk.Object; use Gtk.Object;
with Gtk.Enums; use Gtk.Enums;
with Gtk.Style; use Gtk.Style;
with Gtk.Widget; use Gtk.Widget;
with Ada.Text_Io; use  Ada.Text_Io;
with Win_New_Employee_Pkg; use Win_New_Employee_Pkg;

package body Win_New_Employee_Pkg.Callbacks is

   use Gtk.Arguments;

   --------------------------
   -- On_Btninsert_Pressed --
   --------------------------

   procedure On_Btninsert_Pressed(Object : access Gtk_Button_Record'Class)is

   begin

      Set_Text(win_new_employee.entry3, "");
    
        
   end On_Btninsert_Pressed;

end Win_New_Employee_Pkg.Callbacks;


--package Win_New_Employee_Pkg

with Gtk.Window; use Gtk.Window;
with Gtk.Fixed; use Gtk.Fixed;
with Gtk.GEntry; use Gtk.GEntry;
with Glib.Unicode; use Glib.Unicode;
with Gtk.Label; use Gtk.Label;
with Gtk.Button; use Gtk.Button;

package Win_New_Employee_Pkg is

   type Win_New_Employee_Record is new Gtk_Window_Record with record
      Fixed2 : Gtk_Fixed;
      Entry1 : Gtk_Entry;
      Entry2 : Gtk_Entry;
      Entry3 : Gtk_Entry;
      Label_Surname : Gtk_Label;
      Label_Name : Gtk_Label;
      Label_Code : Gtk_Label;
      Btn_Cancel : Gtk_Button;
      Btn_Insert : Gtk_Button;
   end record;
   type Win_New_Employee_Access is access Win_New_Employee_Record'Class;

   procedure Gtk_New (Win_New_Employee : out Win_New_Employee_Access);
   procedure Initialize (Win_New_Employee : access Win_New_Employee_Record'Class);
   
   Win_New_Employee : Win_New_Employee_Access;

end Win_New_Employee_Pkg;


--package body Win_New_Employee_Pkg

with Glib; use Glib;
with Gtk; use Gtk;
with Gdk.Types; use Gdk.Types;
with Gtk.Widget; use Gtk.Widget;
with Gtk.Enums; use Gtk.Enums;
with Gtkada.Handlers; use Gtkada.Handlers;
with Callbacks_Third; use Callbacks_Third;
with Third_Intl; use Third_Intl;
with Win_New_Employee_Pkg.Callbacks; use Win_New_Employee_Pkg.Callbacks;

package body Win_New_Employee_Pkg is

procedure Gtk_New (Win_New_Employee : out Win_New_Employee_Access) is
begin
   Win_New_Employee := new Win_New_Employee_Record;
   Win_New_Employee_Pkg.Initialize (Win_New_Employee);
end Gtk_New;

procedure Initialize (Win_New_Employee : access Win_New_Employee_Record'Class) is
   pragma Suppress (All_Checks);
begin
   Gtk.Window.Initialize (Win_New_Employee, Window_Toplevel);
   Set_Title (Win_New_Employee, -"New employee");
   Set_Position (Win_New_Employee, Win_Pos_None);
   Set_Modal (Win_New_Employee, False);

   Gtk_New (Win_New_Employee.Fixed2);
   Add (Win_New_Employee, Win_New_Employee.Fixed2);

   Gtk_New (Win_New_Employee.Entry1);
   Set_Editable (Win_New_Employee.Entry1, True);
   Set_Max_Length (Win_New_Employee.Entry1, 0);
   Set_Visibility (Win_New_Employee.Entry1, True);
   Put (Win_New_Employee.Fixed2, Win_New_Employee.Entry1, 112, 8);

   Gtk_New (Win_New_Employee.Entry2);
   Set_Editable (Win_New_Employee.Entry2, True);
   Set_Max_Length (Win_New_Employee.Entry2, 0);
   Set_Visibility (Win_New_Employee.Entry2, True);
   Put (Win_New_Employee.Fixed2, Win_New_Employee.Entry2, 112, 32);

   Gtk_New (Win_New_Employee.Entry3);
   Set_Editable (Win_New_Employee.Entry3, True);
   Set_Max_Length (Win_New_Employee.Entry3, 0);
   Set_Visibility (Win_New_Employee.Entry3, True);
   Put (Win_New_Employee.Fixed2, Win_New_Employee.Entry3, 112, 56);

   Gtk_New (Win_New_Employee.Label_Surname, -("Surname"));
   Set_Alignment (Win_New_Employee.Label_Surname, 0.5, 0.5);
   Set_Padding (Win_New_Employee.Label_Surname, 0, 0);
   Set_Justify (Win_New_Employee.Label_Surname, Justify_Left);
   Set_Line_Wrap (Win_New_Employee.Label_Surname, False);
   Set_Selectable (Win_New_Employee.Label_Surname, False);
   Set_Use_Markup (Win_New_Employee.Label_Surname, False);
   Set_Use_Underline (Win_New_Employee.Label_Surname, False);
   Put (Win_New_Employee.Fixed2, Win_New_Employee.Label_Surname, 8, 32);

   Gtk_New (Win_New_Employee.Label_Name, -("Name"));
   Set_Alignment (Win_New_Employee.Label_Name, 0.5, 0.5);
   Set_Padding (Win_New_Employee.Label_Name, 0, 0);
   Set_Justify (Win_New_Employee.Label_Name, Justify_Center);
   Set_Line_Wrap (Win_New_Employee.Label_Name, False);
   Set_Selectable (Win_New_Employee.Label_Name, False);
   Set_Use_Markup (Win_New_Employee.Label_Name, False);
   Set_Use_Underline (Win_New_Employee.Label_Name, False);
   Put (Win_New_Employee.Fixed2, Win_New_Employee.Label_Name, 8, 8);

   Gtk_New (Win_New_Employee.Label_Code, -("Code"));
   Set_Alignment (Win_New_Employee.Label_Code, 0.5, 0.5);
   Set_Padding (Win_New_Employee.Label_Code, 0, 0);
   Set_Justify (Win_New_Employee.Label_Code, Justify_Left);
   Set_Line_Wrap (Win_New_Employee.Label_Code, False);
   Set_Selectable (Win_New_Employee.Label_Code, False);
   Set_Use_Markup (Win_New_Employee.Label_Code, False);
   Set_Use_Underline (Win_New_Employee.Label_Code, False);
   Put (Win_New_Employee.Fixed2, Win_New_Employee.Label_Code, 8, 56);

   Gtk_New (Win_New_Employee.Btn_Cancel, -"Cancel");
   Set_Relief (Win_New_Employee.Btn_Cancel, Relief_Normal);
   Put (Win_New_Employee.Fixed2, Win_New_Employee.Btn_Cancel, 344, 272);

   Gtk_New (Win_New_Employee.Btn_Insert, -"Insert");
   Set_Relief (Win_New_Employee.Btn_Insert, Relief_Normal);
   Put (Win_New_Employee.Fixed2, Win_New_Employee.Btn_Insert, 288, 272);
   Button_Callback.Connect
     (Win_New_Employee.Btn_Insert, "pressed",
      Button_Callback.To_Marshaller (On_Btninsert_Pressed'Access), False);

end Initialize;

end Win_New_Employee_Pkg;



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Access check failed
  2004-01-03 14:03 Access " gilmour
@ 2004-01-03 18:51 ` Stephen Leake
  2004-01-04 13:31   ` gilmour
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Leake @ 2004-01-03 18:51 UTC (permalink / raw)
  To: comp.lang.ada

gilmour@banda.lv (gilmour) writes:

> Why when I press 'Insert' button, following error appears?
> "CONSTRAINT_ERROR: win_new_employee_pkg.ads:25 access check failed"
> I'am using GtkAda-2.2.0

>    procedure On_Btninsert_Pressed(Object : access Gtk_Button_Record'Class)is
> 
>    begin
> 
>       Set_Text(win_new_employee.entry3, "");

This is referencing Win_New_Employee_Pkg.Win_New_Employee, which is
never set, so it is null, so you get an access check failure.

You need to get the parent of the parent of Object; that is the top
level window containing Entry3.

>    end On_Btninsert_Pressed;
> 
> end Win_New_Employee_Pkg.Callbacks;

> procedure Gtk_New (Win_New_Employee : out Win_New_Employee_Access) is
> begin
>    Win_New_Employee := new Win_New_Employee_Record;

This is the out parameter Win_New_Employee, _not_ the global
Win_New_Employee_Pkg.Win_New_Employee.

>    Win_New_Employee_Pkg.Initialize (Win_New_Employee);
> end Gtk_New;
> 

Here is a typical event handler from one of my applications:

procedure On_Enabled_Clicked (Button : access Gtk.Button.Gtk_Button_Record'Class)
is
  Check_Button : constant Gtk.Check_Button.Gtk_Check_Button := Gtk.Check_Button.Gtk_Check_Button (Button);
  View         : constant Gtk_View                          := Gtk_View (Gtk.Button.Get_Parent (Button));
begin
  View.Data.Enabled := Gtk.Check_Button.Get_Active (Check_Button);
end On_Enabled_Clicked;

Hope this helps.

There is also a GtkAda mailing list; see http://libre.act-europe.fr/

-- 
-- Stephe




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Access check failed
  2004-01-03 18:51 ` Stephen Leake
@ 2004-01-04 13:31   ` gilmour
  0 siblings, 0 replies; 5+ messages in thread
From: gilmour @ 2004-01-04 13:31 UTC (permalink / raw)


> You need to get the parent of the parent of Object; that is the top
> level window containing Entry3.

It works. Many thanks, Stephen!



^ permalink raw reply	[flat|nested] 5+ messages in thread

* access check failed
@ 2004-09-03 12:11 Matthias Teege
  2004-09-03 21:19 ` Stephen Leake
  0 siblings, 1 reply; 5+ messages in thread
From: Matthias Teege @ 2004-09-03 12:11 UTC (permalink / raw)


Moin,

I'm playing with gtk ada and try to integrate some code borrowd from
another gtkada project. The code push messages to the statusbar. It
looks like that:

procedure call_statusbar (text : in string)
is
     my_id   : context_ID := Get_Context_ID(Window1.statusbar1,"Hallo");
     message : message_ID;
begin
     message := Push(Window1.statusbar1,my_id,text);
end call_statusbar;

Now I try to use this procedure in callback procedure:

   procedure On_Combo5_Realize
     (Object  : access Gtk_Combo_Record'Class;
      Params  : Gtk.Arguments.Gtk_Args;
      Window1 : Window1_Access)
   is
      Combo_Items : String_List.Glist;
   begin
      Gadra.Fill_Combo(Window1.Connection.ALL, Combo_Items,"mdt","lnd");
      Combo.Set_Popdown_Strings (Window1.Combo5, Combo_Items);
      Free_String_List (Combo_Items);
      Call_Statusbar("Hello");
   end On_Combo5_Realize;

The code compiles but if I try to run it, it gives me

./window1

(window1:5678): Gtk-WARNING **: Invalid input string
*** NOTICE : WARNING:  there is no transaction in progress

raised CONSTRAINT_ERROR : window1_pkg.ads:142 access check failed

window1_pkg.ads:142 looks like that

....
      Label4 : Gtk_Label;
      Statusbar1 : Gtk_Statusbar;
      Connection : Connection_Access;
   end record;
   type Window1_Access is access all Window1_Record'Class;

   procedure Gtk_New (Window1 : out Window1_Access);
   procedure Initialize (Window1 : access Window1_Record'Class);

L142->   Window1 : Window1_Access;
end Window1_Pkg;

If I remove the call_statusbar call the programm runs. What is the
"access check" and why does it fail?

Thanks
Matthias

-- 
Matthias Teege -- http://www.mteege.de
make world not war



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: access check failed
  2004-09-03 12:11 access check failed Matthias Teege
@ 2004-09-03 21:19 ` Stephen Leake
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Leake @ 2004-09-03 21:19 UTC (permalink / raw)
  To: comp.lang.ada

Matthias Teege <matthias-dated@mteege.de> writes:

> Moin,
> 
> I'm playing with gtk ada and try to integrate some code borrowd from
> another gtkada project. 

You should ask on the gtkada mailing list; see
http://lists.act-europe.fr/mailman/listinfo/gtkada 

> The code push messages to the statusbar. It looks like that:

I'm not familiar with Gtk_Statusbar, so I can't help you here.

-- 
-- Stephe




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-09-03 21:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-03 12:11 access check failed Matthias Teege
2004-09-03 21:19 ` Stephen Leake
  -- strict thread matches above, loose matches on Subject: below --
2004-01-03 14:03 Access " gilmour
2004-01-03 18:51 ` Stephen Leake
2004-01-04 13:31   ` gilmour

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox