From 619b3da9fbb37c57aedfc039cc813f6acf5569be Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Sun, 17 Nov 2024 17:15:53 +1300 Subject: Refactored Finalize subprograms and made note of potential future Widget issues there in fltk.ads --- src/fltk-widgets-menus.adb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/fltk-widgets-menus.adb') diff --git a/src/fltk-widgets-menus.adb b/src/fltk-widgets-menus.adb index f35d53c..5bd67df 100644 --- a/src/fltk-widgets-menus.adb +++ b/src/fltk-widgets-menus.adb @@ -279,21 +279,23 @@ package body FLTK.Widgets.Menus is (Object => FLTK.Menu_Items.Menu_Item, Name => Item_Access); + procedure Extra_Final + (This : in out Menu) is + begin + for Item of This.My_Items loop + Free_Item (Item); + end loop; + Extra_Final (Widget (This)); + end Extra_Final; procedure Finalize (This : in out Menu) is begin - if This.Void_Ptr /= Null_Pointer and then - This in Menu'Class - then - for Item of This.My_Items loop - Free_Item (Item); - end loop; + Extra_Final (This); + if This.Void_Ptr /= Null_Pointer and This.Needs_Dealloc then free_fl_menu (This.Void_Ptr); - This.Void_Ptr := Null_Pointer; end if; - Finalize (Widget (This)); end Finalize; -- cgit