Fixed the crash issue when unbind function is called after E_Client was deleted 17/210317/1
authorInHong Han <inhong1.han@samsung.com>
Thu, 18 Jul 2019 05:31:05 +0000 (14:31 +0900)
committerInHong Han <inhong1.han@samsung.com>
Thu, 18 Jul 2019 05:31:05 +0000 (14:31 +0900)
Change-Id: I4cd1b791e3239a6433b579c2ac111c6872d40211

src/e_mod_input_panel.c

index 72aae2f381ac16d1d7844ada5e4b23a61b49590b..9b1d19710e32516b65b9592dca4eb1d1a01ffce6 100644 (file)
@@ -44,6 +44,8 @@ struct _E_Input_Panel_Surface
    Eina_Bool panel;
    Eina_Bool showing;
    Eina_Bool need_show;
+
+   E_Client_Hook *hook_del;
 };
 
 struct _E_Input_Panel_Floating_Info
@@ -64,10 +66,9 @@ struct _E_Input_Panel_Floating_Info
    } start_position;
 };
 
-E_Input_Panel *g_input_panel = NULL;
-E_Input_Panel_Floating_Info *g_floating_info = NULL;
+static E_Input_Panel *g_input_panel = NULL;
+static E_Input_Panel_Floating_Info *g_floating_info = NULL;
 static Eina_Bool use_main_ec_for_position_set = EINA_FALSE;
-Eina_List *handlers = NULL;
 static Eina_Bool panel_show_need_rerun = EINA_FALSE;
 static Ecore_Timer *g_timer_wait_update  = NULL;
 
@@ -316,10 +317,8 @@ _e_input_panel_surface_resource_destroy(struct wl_resource *resource)
    if (!(input_panel = ips->input_panel)) return;
 
    ec = ips->ec;
-   if (ec)
+   if (ec && (!e_object_is_del(E_OBJECT(ec))))
      {
-        if (e_object_is_del(E_OBJECT(ec))) return;
-
         if (ec->comp_data)
           {
              if (ec->comp_data->mapped)
@@ -341,6 +340,7 @@ _e_input_panel_surface_resource_destroy(struct wl_resource *resource)
    input_panel->surfaces = eina_list_remove(input_panel->surfaces, ips);
    E_FREE_FUNC(ips->eh.rot_change_end, ecore_event_handler_del);
    E_FREE_FUNC(ips->eh.buf_change, ecore_event_handler_del);
+   E_FREE_FUNC(ips->hook_del, e_client_hook_del);
    free(ips);
 }
 
@@ -757,6 +757,18 @@ end:
    return ECORE_CALLBACK_PASS_ON;
 }
 
+static void
+_e_input_panel_client_cb_remove(void *data, E_Client *ec)
+{
+   E_Input_Panel_Surface *ips = data;
+
+   if (ec == ips->ec)
+     {
+        LOGD("Remove IPS's ec. ips:%p, ips->ec:%p", ips, ips->ec);
+        ips->ec = NULL;
+     }
+}
+
 static void
 _e_ips_cb_evas_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
 {
@@ -945,6 +957,8 @@ _e_input_panel_cb_surface_get(struct wl_client *client, struct wl_resource *reso
    ips->ec = ec;
    ips->input_panel = input_panel;
 
+   LOGD("Create IPS.. ips:%p, input_panel:%p, ec:%p", ips, input_panel, ec);
+
    _e_input_panel_surface_append(input_panel, ips, resource);
 
    wl_resource_set_implementation(cdata->shell.surface,
@@ -954,6 +968,8 @@ _e_input_panel_cb_surface_get(struct wl_client *client, struct wl_resource *reso
    ips->eh.rot_change_end =
       ecore_event_handler_add(E_EVENT_CLIENT_ROTATION_CHANGE_END,
                               _e_input_panel_client_cb_rotation_change_end, ips);
+
+   ips->hook_del = e_client_hook_add(E_CLIENT_HOOK_DEL, _e_input_panel_client_cb_remove, ips);
 }