summaryrefslogtreecommitdiff
path: root/src/fltk-file_choosers.adb
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-01-14 01:54:17 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2025-01-14 01:54:17 +1300
commit1ba99737bca1136170f04b3a46659deb042e3fcd (patch)
tree9b42991aa5aed8c76abcd1bf5ba980e249f0de28 /src/fltk-file_choosers.adb
parent88ca2ea14ba6651404cd4ea347ac8f06afdd0558 (diff)
Fixed a number of issues with getting the Ada wrapper back given a C++ widget pointer
Diffstat (limited to 'src/fltk-file_choosers.adb')
-rw-r--r--src/fltk-file_choosers.adb16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/fltk-file_choosers.adb b/src/fltk-file_choosers.adb
index d413f15..3eee496 100644
--- a/src/fltk-file_choosers.adb
+++ b/src/fltk-file_choosers.adb
@@ -31,6 +31,12 @@ package body FLTK.File_Choosers is
-- Functions From C --
------------------------
+ function fl_widget_get_user_data
+ (W : in Storage.Integer_Address)
+ return Storage.Integer_Address;
+ pragma Import (C, fl_widget_get_user_data, "fl_widget_get_user_data");
+ pragma Inline (fl_widget_get_user_data);
+
procedure fl_widget_set_user_data
(W, D : in Storage.Integer_Address);
pragma Import (C, fl_widget_set_user_data, "fl_widget_set_user_data");
@@ -952,8 +958,16 @@ package body FLTK.File_Choosers is
is
C_Addr : Storage.Integer_Address :=
fl_file_chooser_add_extra (This.Void_Ptr, Wrapper (Item).Void_Ptr);
+ Ada_Obj : access Widgets.Widget'Class;
begin
- return Widget_Convert.To_Pointer (Storage.To_Address (C_Addr));
+ if C_Addr /= Null_Pointer then
+ C_Addr := fl_widget_get_user_data (C_Addr);
+ pragma Assert (C_Addr /= Null_Pointer);
+ Ada_Obj := Widget_Convert.To_Pointer (Storage.To_Address (C_Addr));
+ end if;
+ return Ada_Obj;
+ exception
+ when Chk.Assertion_Error => raise Internal_FLTK_Error;
end Eject_Extra;