From 1ba99737bca1136170f04b3a46659deb042e3fcd Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Tue, 14 Jan 2025 01:54:17 +1300 Subject: Fixed a number of issues with getting the Ada wrapper back given a C++ widget pointer --- src/fltk-tooltips.adb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/fltk-tooltips.adb') diff --git a/src/fltk-tooltips.adb b/src/fltk-tooltips.adb index 84e4160..ccdb649 100644 --- a/src/fltk-tooltips.adb +++ b/src/fltk-tooltips.adb @@ -6,6 +6,7 @@ with + Ada.Assertions, Interfaces.C, System.Address_To_Access_Conversions; @@ -17,6 +18,11 @@ use type package body FLTK.Tooltips is + package Chk renames Ada.Assertions; + + + + ------------------------ -- Functions From C -- ------------------------ @@ -174,13 +180,16 @@ package body FLTK.Tooltips is return access FLTK.Widgets.Widget'Class is Widget_Ptr : Storage.Integer_Address := fl_tooltip_get_current; + Actual_Widget : access FLTK.Widgets.Widget'Class; begin if Widget_Ptr /= Null_Pointer then - return Widget_Convert.To_Pointer - (Storage.To_Address (fl_widget_get_user_data (Widget_Ptr))); - else - return null; + Widget_Ptr := fl_widget_get_user_data (Widget_Ptr); + pragma Assert (Widget_Ptr /= Null_Pointer); + Actual_Widget := Widget_Convert.To_Pointer (Storage.To_Address (Widget_Ptr)); end if; + return Actual_Widget; + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error; end Get_Target; -- cgit