diff --git a/src/core/lv_global.h b/src/core/lv_global.h index de64dd760..24f192940 100644 --- a/src/core/lv_global.h +++ b/src/core/lv_global.h @@ -67,6 +67,7 @@ struct _lv_freetype_context_t; typedef struct _lv_global_t { bool inited; + bool deinit_in_progress; /**< Can be used e.g. in the LV_EVENT_DELETE to deinit the drivers too */ lv_ll_t disp_ll; struct _lv_display_t * disp_refresh; diff --git a/src/dev/sdl/lv_sdl_window.c b/src/dev/sdl/lv_sdl_window.c index 4cc52de36..559e6f180 100644 --- a/src/dev/sdl/lv_sdl_window.c +++ b/src/dev/sdl/lv_sdl_window.c @@ -11,6 +11,7 @@ #include #include "../../core/lv_refr.h" #include "../../stdlib/lv_string.h" +#include "../../core/lv_global.h" #define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" issue*/ #include LV_SDL_INCLUDE_PATH @@ -63,6 +64,8 @@ static bool inited = false; **********************/ static lv_timer_t * event_handler_timer; +#define lv_deinit_in_progress LV_GLOBAL_DEFAULT()->deinit_in_progress + /********************** * MACROS **********************/ @@ -359,6 +362,10 @@ static void res_chg_event_cb(lv_event_t * e) static void release_disp_cb(lv_event_t * e) { + if(lv_deinit_in_progress) { + lv_sdl_quit(); + } + lv_display_t * disp = (lv_display_t *) lv_event_get_user_data(e); lv_sdl_window_t * dsc = lv_display_get_driver_data(disp); diff --git a/src/lv_init.c b/src/lv_init.c index 1cc8439dd..415931ad7 100644 --- a/src/lv_init.c +++ b/src/lv_init.c @@ -37,6 +37,7 @@ * DEFINES *********************/ #define lv_initialized LV_GLOBAL_DEFAULT()->inited +#define lv_deinit_in_progress LV_GLOBAL_DEFAULT()->deinit_in_progress /********************** * TYPEDEFS @@ -296,6 +297,8 @@ void lv_deinit(void) return; } + lv_deinit_in_progress = true; + #if LV_USE_SYSMON _lv_sysmon_builtin_deinit(); #endif