diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-14 01:54:17 +1300 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-14 01:54:17 +1300 |
commit | 1ba99737bca1136170f04b3a46659deb042e3fcd (patch) | |
tree | 9b42991aa5aed8c76abcd1bf5ba980e249f0de28 /src/fltk-widgets-menus.adb | |
parent | 88ca2ea14ba6651404cd4ea347ac8f06afdd0558 (diff) |
Fixed a number of issues with getting the Ada wrapper back given a C++ widget pointer
Diffstat (limited to 'src/fltk-widgets-menus.adb')
-rw-r--r-- | src/fltk-widgets-menus.adb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/fltk-widgets-menus.adb b/src/fltk-widgets-menus.adb index be46a72..28653ec 100644 --- a/src/fltk-widgets-menus.adb +++ b/src/fltk-widgets-menus.adb @@ -6,8 +6,9 @@ with - Interfaces.C.Strings, - Ada.Unchecked_Deallocation; + Ada.Assertions, + Ada.Unchecked_Deallocation, + Interfaces.C.Strings; use type @@ -19,6 +20,11 @@ use type package body FLTK.Widgets.Menus is + package Chk renames Ada.Assertions; + + + + ------------------------ -- Functions From C -- ------------------------ @@ -272,11 +278,15 @@ package body FLTK.Widgets.Menus is procedure Item_Hook (M, U : in Storage.Integer_Address) is - Ada_Widget : access Widget'Class := - Widget_Convert.To_Pointer (Storage.To_Address (fl_widget_get_user_data (M))); + C_Ptr : Storage.Integer_Address := fl_widget_get_user_data (M); + Ada_Widget : access Widget'Class; Action : Widget_Callback := Callback_Convert.To_Access (U); begin + pragma Assert (C_Ptr /= Null_Pointer); + Ada_Widget := Widget_Convert.To_Pointer (Storage.To_Address (C_Ptr)); Action.all (Ada_Widget.all); + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error; end Item_Hook; |