Fix destroy handle bug 69/118669/1 accepted/tizen/common/20170313.162603 accepted/tizen/ivi/20170313.225641 accepted/tizen/mobile/20170313.225556 accepted/tizen/tv/20170313.225609 accepted/tizen/unified/20170314.015025 accepted/tizen/wearable/20170313.225625 submit/tizen/20170313.132655
authorHyunho Kang <hhstark.kang@samsung.com>
Mon, 13 Mar 2017 13:19:24 +0000 (22:19 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Mon, 13 Mar 2017 13:20:55 +0000 (22:20 +0900)
Change-Id: Ifc796724e8db62557fab4c80e6e912dbe022f169
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
screen_connector_watcher/src/screen_connector_toolkit.c
screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c

index 98864ff..b9f31e4 100644 (file)
@@ -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;
index a442f36..35b864b 100644 (file)
@@ -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;