From: Hyunho Kang Date: Mon, 13 Mar 2017 13:19:24 +0000 (+0900) Subject: Fix destroy handle bug X-Git-Tag: accepted/tizen/3.0/common/20170331.152145~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F13%2F122113%2F1;p=platform%2Fcore%2Fappfw%2Fscreen-connector.git Fix destroy handle bug Change-Id: Ifc796724e8db62557fab4c80e6e912dbe022f169 Signed-off-by: Hyunho Kang (cherry picked from commit 505fb90a88d192f7a2311c49fc3693a4c2e82415) --- diff --git a/screen_connector_watcher/src/screen_connector_toolkit.c b/screen_connector_watcher/src/screen_connector_toolkit.c index f3e9028..910d73f 100644 --- a/screen_connector_watcher/src/screen_connector_toolkit.c +++ b/screen_connector_watcher/src/screen_connector_toolkit.c @@ -154,8 +154,10 @@ static void __destroy_type_h(gpointer data) if (type_h->aul_handle) aul_screen_connector_remove_screen_viewer(type_h->aul_handle); - if (type_h->toolkit_table) + if (type_h->toolkit_table) { g_hash_table_destroy(type_h->toolkit_table); + type_h->toolkit_table = NULL; + } free(type_h); } @@ -202,20 +204,17 @@ static void __aul_screen_viewer_cb(const char *appid, const char *instance_id, EXPORT_API int screen_connector_toolkit_init(screen_connector_screen_type_e type) { int ret = 0; - int *key; screen_connector_type_h type_h; ret = screen_connector_trs_init(); if (__type_table == NULL) - __type_table = g_hash_table_new_full(g_int_hash, g_int_equal, free, __destroy_type_h); + __type_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __destroy_type_h); - type_h = g_hash_table_lookup(__type_table, &type); + type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type)); if (type_h == NULL) { - key = (int *)calloc(1, sizeof(int)); - *key = type; type_h = (screen_connector_type_h)calloc(1, sizeof(struct _screen_connector_type_h)); - g_hash_table_insert(__type_table, key, type_h); + g_hash_table_insert(__type_table, GINT_TO_POINTER(type), type_h); } return ret; @@ -231,9 +230,9 @@ EXPORT_API int screen_connector_toolkit_fini(screen_connector_screen_type_e type return 0; } - type_h = g_hash_table_lookup(__type_table, &type); + type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type)); if (type_h) - g_hash_table_remove(__type_table, &type); + g_hash_table_remove(__type_table, GINT_TO_POINTER(type)); if (g_hash_table_size(__type_table) == 0) { ret = screen_connector_trs_fini(); @@ -284,7 +283,7 @@ EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_add(screen_connec return NULL; } - type_h = g_hash_table_lookup(__type_table, &type); + type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type)); if (type_h == NULL) { LOGE("type %d is not initialized !!", type); return NULL; diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index 5d5baa0..70f9a17 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -61,26 +61,25 @@ static void __destroy_type_h(gpointer data) if (!type_h) return; - if (type_h->toolkit_table) + if (type_h->toolkit_table) { g_hash_table_destroy(type_h->toolkit_table); + type_h->toolkit_table = NULL; + } free(type_h); } EXPORT_API int screen_connector_toolkit_evas_init(Evas_Object *win, screen_connector_screen_type_e type) { screen_connector_type_evas_h type_h; - int *key; if (__type_table == NULL) - __type_table = g_hash_table_new_full(g_int_hash, g_int_equal, free, __destroy_type_h); + __type_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __destroy_type_h); - type_h = g_hash_table_lookup(__type_table, &type); + type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type)); if (type_h == NULL) { - key = (int *)calloc(1, sizeof(int)); - *key = type; type_h = (screen_connector_type_evas_h)calloc(1, sizeof(struct _screen_connector_type_evas_h)); - g_hash_table_insert(__type_table, key, type_h); + g_hash_table_insert(__type_table, GINT_TO_POINTER(type), type_h); type_h->toolkit_table = g_hash_table_new(g_direct_hash, g_direct_equal); if (!type_h->toolkit_table) { @@ -102,11 +101,13 @@ EXPORT_API int screen_connector_toolkit_evas_fini(screen_connector_screen_type_e return 0; } - type_h = g_hash_table_lookup(__type_table, &type); + type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type)); if (type_h) { - if (type_h->toolkit_table) + if (type_h->toolkit_table) { g_hash_table_destroy(type_h->toolkit_table); - g_hash_table_remove(__type_table, &type); + type_h->toolkit_table = NULL; + } + g_hash_table_remove(__type_table, GINT_TO_POINTER(type)); } if (g_hash_table_size(__type_table) == 0) { @@ -582,7 +583,7 @@ EXPORT_API screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add(scr screen_connector_type_evas_h type_h; int int_type = type; - type_h = g_hash_table_lookup(__type_table, &int_type); + type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(int_type)); if (type_h == NULL) { LOGE("type %d is not initialized !!", type); return NULL; @@ -829,7 +830,7 @@ EXPORT_API screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add_by_ screen_connector_type_evas_h type_h; char rid_str[32]; - type_h = g_hash_table_lookup(__type_table, &type); + type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type)); if (type_h == NULL) { LOGE("type %d is not initialized !!", type); return NULL;