From d45103f2445ed59b7ba78faeae8061327c4ab976 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Tue, 15 May 2018 16:30:58 +1000 Subject: Fixed errors with Event Dispatch and null string pointers --- src/fltk-widgets.adb | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/fltk-widgets.adb') diff --git a/src/fltk-widgets.adb b/src/fltk-widgets.adb index 40890c4..73d3e17 100644 --- a/src/fltk-widgets.adb +++ b/src/fltk-widgets.adb @@ -11,6 +11,7 @@ use type Interfaces.C.int, Interfaces.C.unsigned, + Interfaces.C.Strings.chars_ptr, System.Address; @@ -844,10 +845,16 @@ package body FLTK.Widgets is function Get_Tooltip (This : in Widget) - return String is + return String + is + Ptr : Interfaces.C.Strings.chars_ptr := fl_widget_tooltip (This.Void_Ptr); begin - -- no need for dealloc - return Interfaces.C.Strings.Value (fl_widget_tooltip (This.Void_Ptr)); + if Ptr = Interfaces.C.Strings.Null_Ptr then + return ""; + else + -- no need for dealloc + return Interfaces.C.Strings.Value (Ptr); + end if; end Get_Tooltip; @@ -863,9 +870,15 @@ package body FLTK.Widgets is function Get_Label (This : in Widget) - return String is + return String + is + Ptr : Interfaces.C.Strings.chars_ptr := fl_widget_get_label (This.Void_Ptr); begin - return Interfaces.C.Strings.Value (fl_widget_get_label (This.Void_Ptr)); + if Ptr = Interfaces.C.Strings.Null_Ptr then + return ""; + else + return Interfaces.C.Strings.Value (Ptr); + end if; end Get_Label; -- cgit