From 385d51b18ecc43d3e68b4b30c448962cfbdca6dd Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 29 Jan 2023 20:42:03 +0000 Subject: [PATCH] Delegate UI_DIALOG deletion back to window_close UI_DIALOG::event_handler's case `EVENT_WINDOW_CLOSE` can only be hit if `rval == window_event_result::ignored`. Any other result returned before entering the switch. If `rval == ignored`, then returning `ignored` will cause `window_close` to delete the object. Delegate to that deletion instead of having an explicit deletion in this handler. --- common/ui/dialog.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/common/ui/dialog.cpp b/common/ui/dialog.cpp index 9ba8f9d61..cf72951fa 100644 --- a/common/ui/dialog.cpp +++ b/common/ui/dialog.cpp @@ -95,10 +95,6 @@ window_event_result UI_DIALOG::event_handler(const d_event &event) return rval; } - case EVENT_WINDOW_CLOSE: - if (rval != window_event_result::deleted) // check if handler already deleted dialog (e.g. if UI_DIALOG was subclassed) - delete this; - return window_event_result::deleted; // free the window in any case (until UI_DIALOG is subclass of window) default: return window_event_result::ignored; }