ecore_wl2: refactor global cleanup in shutdown paths

Both session recovery and regular disconnect do this, so make
it a function to ensure they stay in sync.
This commit is contained in:
Derek Foreman 2017-04-19 16:35:36 -05:00
parent c4b22eb59c
commit 9d3eaac080
1 changed files with 19 additions and 24 deletions

View File

@ -264,6 +264,23 @@ _recovery_timer(Ecore_Wl2_Display *ewd)
return EINA_FALSE;
}
static void
_ecore_wl2_display_globals_cleanup(Ecore_Wl2_Display *ewd)
{
if (ewd->wl.session_recovery)
zwp_e_session_recovery_destroy(ewd->wl.session_recovery);
if (ewd->wl.www) www_destroy(ewd->wl.www);
if (ewd->wl.zxdg_shell) zxdg_shell_v6_destroy(ewd->wl.zxdg_shell);
if (ewd->wl.xdg_shell) xdg_shell_destroy(ewd->wl.xdg_shell);
if (ewd->wl.shm) wl_shm_destroy(ewd->wl.shm);
if (ewd->wl.data_device_manager)
wl_data_device_manager_destroy(ewd->wl.data_device_manager);
if (ewd->wl.compositor) wl_compositor_destroy(ewd->wl.compositor);
if (ewd->wl.subcompositor) wl_subcompositor_destroy(ewd->wl.subcompositor);
if (ewd->wl.registry) wl_registry_destroy(ewd->wl.registry);
}
static void
_recovery_timer_add(Ecore_Wl2_Display *ewd)
{
@ -281,18 +298,7 @@ _recovery_timer_add(Ecore_Wl2_Display *ewd)
ewd->shell_done = EINA_FALSE;
if (ewd->wl.session_recovery)
zwp_e_session_recovery_destroy(ewd->wl.session_recovery);
if (ewd->wl.www) www_destroy(ewd->wl.www);
if (ewd->wl.zxdg_shell) zxdg_shell_v6_destroy(ewd->wl.zxdg_shell);
if (ewd->wl.xdg_shell) xdg_shell_destroy(ewd->wl.xdg_shell);
if (ewd->wl.shm) wl_shm_destroy(ewd->wl.shm);
if (ewd->wl.data_device_manager)
wl_data_device_manager_destroy(ewd->wl.data_device_manager);
if (ewd->wl.compositor) wl_compositor_destroy(ewd->wl.compositor);
if (ewd->wl.subcompositor) wl_subcompositor_destroy(ewd->wl.subcompositor);
if (ewd->wl.registry) wl_registry_destroy(ewd->wl.registry);
_ecore_wl2_display_globals_cleanup(ewd);
memset(&ewd->wl, 0, sizeof(ewd->wl));
EINA_INLIST_FOREACH_SAFE(ewd->inputs, tmp, input)
@ -578,18 +584,7 @@ _ecore_wl2_display_cleanup(Ecore_Wl2_Display *ewd)
eina_hash_free(ewd->globals);
if (ewd->wl.session_recovery)
zwp_e_session_recovery_destroy(ewd->wl.session_recovery);
if (ewd->wl.www) www_destroy(ewd->wl.www);
if (ewd->wl.zxdg_shell) zxdg_shell_v6_destroy(ewd->wl.zxdg_shell);
if (ewd->wl.xdg_shell) xdg_shell_destroy(ewd->wl.xdg_shell);
if (ewd->wl.shm) wl_shm_destroy(ewd->wl.shm);
if (ewd->wl.data_device_manager)
wl_data_device_manager_destroy(ewd->wl.data_device_manager);
if (ewd->wl.compositor) wl_compositor_destroy(ewd->wl.compositor);
if (ewd->wl.subcompositor) wl_subcompositor_destroy(ewd->wl.subcompositor);
if (ewd->wl.registry) wl_registry_destroy(ewd->wl.registry);
_ecore_wl2_display_globals_cleanup(ewd);
}
Ecore_Wl2_Window *