From f4b91986a81b1db1de8294f4f2014bc1c993af7e Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Thu, 30 Oct 2014 10:27:16 +0900 Subject: [PATCH] display: unregister display change listener remove some leaks Change-Id: I19f870a518d5485d60fbbb06f405c00fa6cda515 Signed-off-by: GiWoong Kim --- tizen/src/display/maru_display.c | 4 ++-- tizen/src/display/maru_sdl.c | 19 ++++++++++++++----- tizen/src/display/maru_shm.c | 14 ++++++++++---- vl.c | 14 +++++++------- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/tizen/src/display/maru_display.c b/tizen/src/display/maru_display.c index 860dbcae64..8403cb5e6c 100644 --- a/tizen/src/display/maru_display.c +++ b/tizen/src/display/maru_display.c @@ -47,6 +47,8 @@ static void maru_display_fini(void) if (mdcl->fini) { mdcl->fini(); } + + g_free(mdcl); } static void maru_display_notify_exit(Notifier *notifier, void *data) { @@ -67,7 +69,6 @@ void maru_display_early_init(DisplayType display_type) } } -//TODO: interface void maru_display_init(DisplayState *ds, DisplayType display_type, int full_screen) { INFO("init qemu display\n"); @@ -96,7 +97,6 @@ void maru_display_init(DisplayState *ds, DisplayType display_type, int full_scre break; } - //register_displaychangelistener(mdcl->dcl); screenshot = g_malloc0(sizeof(MaruScreenShot)); screenshot->pixels = NULL; screenshot->request = false; diff --git a/tizen/src/display/maru_sdl.c b/tizen/src/display/maru_sdl.c index 66f916ca2f..4964bc15a5 100644 --- a/tizen/src/display/maru_sdl.c +++ b/tizen/src/display/maru_sdl.c @@ -45,6 +45,8 @@ MULTI_DEBUG_CHANNEL(tizen, maru_sdl); +static DisplayChangeListener *dcl; + static QEMUBH *sdl_init_bh; static QEMUBH *sdl_resize_bh; static QEMUBH *sdl_update_bh; @@ -483,6 +485,8 @@ static void maru_sdl_init_bh(void *opaque) SDL_GetWMInfo(&info); #endif + sdl_resize_bh = qemu_bh_new(maru_sdl_resize_bh, NULL); + sdl_update_bh = qemu_bh_new(maru_sdl_update_bh, NULL); qemu_bh_schedule(sdl_resize_bh); #ifdef SDL_THREAD @@ -537,13 +541,18 @@ static void maru_sdl_quit(void) qemu_cond_destroy(&sdl_cond); qemu_mutex_destroy(&sdl_mutex); #endif + + unregister_displaychangelistener(dcl); + g_free(dcl); } static void maru_sdl_resize(void) { INFO("maru sdl resize\n"); - qemu_bh_schedule(sdl_resize_bh); + if (sdl_resize_bh != NULL) { + qemu_bh_schedule(sdl_resize_bh); + } } static void maru_sdl_update(void) @@ -601,8 +610,9 @@ static void maru_sdl_init(uint64 swt_handle, qemu_bh_schedule(sdl_init_bh); } -void maru_sdl_pre_init(MaruDisplayChangeListener *mdcl) { - DisplayChangeListener *dcl = g_malloc0(sizeof(DisplayChangeListener)); +void maru_sdl_pre_init(MaruDisplayChangeListener *mdcl) +{ + dcl = g_malloc0(sizeof(DisplayChangeListener)); dcl->ops = &dcl_ops; mdcl->surface_init = maru_sdl_init; @@ -614,12 +624,11 @@ void maru_sdl_pre_init(MaruDisplayChangeListener *mdcl) { mdcl->set_interpolation = maru_sdl_set_interpolation; sdl_init_bh = qemu_bh_new(maru_sdl_init_bh, NULL); - sdl_resize_bh = qemu_bh_new(maru_sdl_resize_bh, NULL); - sdl_update_bh = qemu_bh_new(maru_sdl_update_bh, NULL); #ifdef SDL_THREAD qemu_mutex_init(&sdl_mutex); qemu_cond_init(&sdl_cond); #endif + register_displaychangelistener(dcl); } diff --git a/tizen/src/display/maru_shm.c b/tizen/src/display/maru_shm.c index 414491ae51..6d4213ffa0 100644 --- a/tizen/src/display/maru_shm.c +++ b/tizen/src/display/maru_shm.c @@ -41,6 +41,8 @@ MULTI_DEBUG_CHANNEL(tizen, maru_shm); +static DisplayChangeListener *dcl; + static DisplaySurface *dpy_surface; static void *shared_memory = (void *) 0; static int skin_shmid; @@ -228,6 +230,9 @@ static void maru_shm_quit(void) INFO("number of current attaches = %d\n", (int)shm_info.shm_nattch); } + + unregister_displaychangelistener(dcl); + g_free(dcl); } static void maru_shm_resize(void) @@ -288,15 +293,16 @@ static void maru_shm_init(uint64 swt_handle, INFO("Memory attached at 0x%X\n", (int)shared_memory); } - -void maru_shm_pre_init(MaruDisplayChangeListener *mdcl) { - DisplayChangeListener *dcl = g_malloc0(sizeof(DisplayChangeListener)); +void maru_shm_pre_init(MaruDisplayChangeListener *mdcl) +{ + dcl = g_malloc0(sizeof(DisplayChangeListener)); dcl->ops = &dcl_ops; - register_displaychangelistener(dcl); mdcl->surface_init = maru_shm_init; mdcl->fini = maru_shm_quit; mdcl->resize = maru_shm_resize; + + register_displaychangelistener(dcl); } diff --git a/vl.c b/vl.c index 411a003f2b..0295dac94c 100644 --- a/vl.c +++ b/vl.c @@ -2356,19 +2356,19 @@ static DisplayType select_display(const char *p) exit(1); #endif #ifdef CONFIG_MARU +# ifdef CONFIG_SDL } else if (strstart(p, "maru_sdl", &opts)) { -#ifdef CONFIG_SDL display = DT_MARU_SDL; -#endif +# endif +# ifdef CONFIG_USE_SHM } else if (strstart(p, "maru_shm", &opts)) { -#ifdef CONFIG_USE_SHM display = DT_MARU_SHM; -#endif +# endif +# ifdef CONFIG_QT } else if (strstart(p, "maru_qt", &opts)) { -#ifdef CONFIG_QT display = DT_MARU_QT; -#endif -#endif +# endif +#endif /* CONFIG_MARU */ } else if (strstart(p, "none", &opts)) { display = DT_NONE; } else { -- 2.34.1