From ee967448bae4733aec70ba128062bc3357a2f0df Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Thu, 6 Feb 2025 21:55:19 +1300 Subject: Widget deletion inside callbacks is now safe --- body/c_fl_sys_menu_bar.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'body/c_fl_sys_menu_bar.cpp') diff --git a/body/c_fl_sys_menu_bar.cpp b/body/c_fl_sys_menu_bar.cpp index fbd6e34..7f28574 100644 --- a/body/c_fl_sys_menu_bar.cpp +++ b/body/c_fl_sys_menu_bar.cpp @@ -7,6 +7,7 @@ #include #include #include "c_fl_sys_menu_bar.h" +#include "c_fl.h" @@ -53,7 +54,11 @@ SYSMENUBAR new_fl_sys_menu_bar(int x, int y, int w, int h, char* label) { } void free_fl_sys_menu_bar(SYSMENUBAR m) { - delete static_cast(m); + if (fl_inside_callback) { + fl_delete_widget(m); + } else { + delete static_cast(m); + } } -- cgit