From: Hyunho Kang Date: Mon, 13 Mar 2017 13:19:24 +0000 (+0900) Subject: Fix destroy handle bug X-Git-Tag: accepted/tizen/common/20170313.162603^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=505fb90a88d192f7a2311c49fc3693a4c2e82415;p=platform%2Fcore%2Fappfw%2Fscreen-connector.git Fix destroy handle bug Change-Id: Ifc796724e8db62557fab4c80e6e912dbe022f169 Signed-off-by: Hyunho Kang --- diff --git a/screen_connector_watcher/src/screen_connector_toolkit.c b/screen_connector_watcher/src/screen_connector_toolkit.c index 98864ff..b9f31e4 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(); @@ -274,7 +273,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 a442f36..35b864b 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; @@ -830,7 +831,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;