From de3e4815ee4bc6e3b3239a9fdd80f3f68c697fb0 Mon Sep 17 00:00:00 2001 From: George Sokianos Date: Sun, 2 Jan 2022 19:04:18 +0000 Subject: [PATCH] Removed clearQuit() and applied commit 456f6ed changes to free the resources --- data/core/init.lua | 6 ++++-- src/main.c | 11 +---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/data/core/init.lua b/data/core/init.lua index 89eca744..21cb3e85 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -512,6 +512,7 @@ function core.init() core.redraw = true core.visited_files = {} core.restart_request = false + core.quite_request = false core.replacements = whitespace_replacements() core.root_view = RootView() @@ -668,7 +669,8 @@ local function quit_with_function(quit_fn, force) end function core.quit(force) - quit_with_function(os.exit, force) + -- quit_with_function(os.exit, force) + quit_with_function(function() core.quit_request = true end, force) end @@ -1044,7 +1046,7 @@ function core.run() core.frame_start = system.get_time() local did_redraw = core.step() local need_more_work = run_threads() - if core.restart_request then break end + if core.restart_request or core.quit_request then break end if not did_redraw and not need_more_work then idle_iterations = idle_iterations + 1 -- do not wait of events at idle_iterations = 1 to give a chance at core.step to run diff --git a/src/main.c b/src/main.c index 0b1a86c3..da0a8e9c 100644 --- a/src/main.c +++ b/src/main.c @@ -79,15 +79,6 @@ static void get_exe_filename(char *buf, int sz) { #endif } - -static void clearQuit(void) -{ - rencache_invalidate(); - ren_free_window_resources(); - SDL_Quit(); -} - - static void init_window_icon(void) { #ifndef _WIN32 #include "../icon.inl" @@ -129,7 +120,7 @@ int main(int argc, char **argv) { SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS); SDL_EnableScreenSaver(); SDL_EventState(SDL_DROPFILE, SDL_ENABLE); - atexit(clearQuit); + atexit(SDL_Quit); #ifdef SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR /* Available since 2.0.8 */ SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");