Skip to content

Commit d0216ce

Browse files
T820-012: Fix runtime accessibility check exceptions
Change-Id: I1fe17469e3c0a9cf1f2a86a3561b74a748eeffd7
1 parent 7860b85 commit d0216ce

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

src/gtk-handlers.adb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- GtkAda - Ada95 binding for Gtk+/Gnome --
33
-- --
44
-- Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet --
5-
-- Copyright (C) 1998-2018, AdaCore --
5+
-- Copyright (C) 1998-2020, AdaCore --
66
-- --
77
-- This library is free software; you can redistribute it and/or modify it --
88
-- under terms of the GNU General Public License as published by the Free --
@@ -407,7 +407,10 @@ package body Gtk.Handlers is
407407
new Data_Type_Record'
408408
(Func => To_Handler (Marsh.Func),
409409
Proxy => Marsh.Proxy,
410-
Object => Acc (Slot_Object));
410+
Object => (if Slot_Object /= null then
411+
Widget_Type (Slot_Object.all)'Unchecked_Access
412+
else
413+
null));
411414

412415
begin
413416
return Do_Signal_Connect
@@ -465,7 +468,10 @@ package body Gtk.Handlers is
465468
new Data_Type_Record'
466469
(Func => Cb,
467470
Proxy => null,
468-
Object => Acc (Slot_Object));
471+
Object => (if Slot_Object /= null then
472+
Widget_Type (Slot_Object.all)'Unchecked_Access
473+
else
474+
null));
469475

470476
begin
471477
return Do_Signal_Connect

src/gtkada-mdi-close_button.adb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- GtkAda - Ada95 binding for Gtk+/Gnome --
33
-- --
4-
-- Copyright (C) 2011-2018, AdaCore --
4+
-- Copyright (C) 2011-2020, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify it --
77
-- under terms of the GNU General Public License as published by the Free --
@@ -84,7 +84,10 @@ package body Close_Button is
8484
Get_Style_Context (Button).Add_Class ("mdiCloseButton");
8585
Set_Visible_Window (Button, False);
8686

87-
Button.Child := MDI_Child (Child);
87+
Button.Child := (if Child /= null then
88+
MDI_Child_Record (Child.all)'Unchecked_Access
89+
else
90+
null);
8891
Button.Pressed := False;
8992
Button.Over := False;
9093
Button.Tab_Over := False;

src/gtkada-mdi.adb

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- GtkAda - Ada95 binding for Gtk+/Gnome --
33
-- --
4-
-- Copyright (C) 2001-2019, AdaCore --
4+
-- Copyright (C) 2001-2020, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify it --
77
-- under terms of the GNU General Public License as published by the Free --
@@ -3394,11 +3394,16 @@ package body Gtkada.MDI is
33943394
Widget : access Gtk.Widget.Gtk_Widget_Record'Class) return MDI_Child
33953395
is
33963396
Tmp : Widget_List.Glist;
3397+
Child_Widget : constant Gtk_Widget :=
3398+
(if Widget /= null then
3399+
Gtk_Widget_Record (Widget.all)'Unchecked_Access
3400+
else
3401+
null);
33973402
begin
33983403
Tmp := First (MDI.Items);
33993404

34003405
while Tmp /= Null_List loop
3401-
if MDI_Child (Get_Data (Tmp)).Initial = Gtk_Widget (Widget) then
3406+
if MDI_Child (Get_Data (Tmp)).Initial = Child_Widget then
34023407
return Insert_Child_If_Needed (MDI, MDI_Child (Get_Data (Tmp)));
34033408
end if;
34043409

@@ -3591,7 +3596,8 @@ package body Gtkada.MDI is
35913596
-- Temporary fool the system, so that the child doesn't necessarily
35923597
-- gain the focus. Otherwise, switching a notebook page gives the
35933598
-- child the focus.
3594-
Child.MDI.Focus_Child := MDI_Child (Child);
3599+
Child.MDI.Focus_Child :=
3600+
MDI_Child_Record (Child.all)'Unchecked_Access;
35953601

35963602
-- There could be no parent if we are in all-floating mode
35973603
if Note /= null then
@@ -3724,11 +3730,13 @@ package body Gtkada.MDI is
37243730

37253731
procedure Set_Focus_Child (Child : not null access MDI_Child_Record) is
37263732
Old : constant MDI_Child := Child.MDI.Focus_Child;
3727-
C : constant MDI_Child := MDI_Child (Child);
3733+
C : constant MDI_Child := Child.all'Unchecked_Access;
37283734
Tmp : Boolean;
37293735
pragma Unreferenced (Tmp);
37303736

37313737
Previous_Focus_Child : constant MDI_Child := Child.MDI.Focus_Child;
3738+
Widget : constant Gtk_Widget :=
3739+
Gtk_Widget_Record (Child.all)'Unchecked_Access;
37323740
begin
37333741
if Child.MDI.Loading_Desktop then
37343742
return;
@@ -3752,7 +3760,7 @@ package body Gtkada.MDI is
37523760
-- point (might be called because we insert the child in a notebook
37533761
-- first for instance)
37543762

3755-
if Widget_List.Find (C.MDI.Items, Gtk_Widget (Child)) = Null_List then
3763+
if Widget_List.Find (C.MDI.Items, Widget) = Null_List then
37563764
return;
37573765
end if;
37583766

@@ -3775,8 +3783,8 @@ package body Gtkada.MDI is
37753783
Update_Tab_Color (Get_Notebook (C), True);
37763784

37773785
Ref (C);
3778-
Remove (C.MDI.Items, Gtk_Widget (Child));
3779-
Prepend (C.MDI.Items, Gtk_Widget (Child));
3786+
Remove (C.MDI.Items, Widget);
3787+
Prepend (C.MDI.Items, Widget);
37803788
Unref (C);
37813789

37823790
-- Make sure the page containing Child in a notebook is put on top.

0 commit comments

Comments
 (0)