Fixed the crash issue when unbind function is called after E_Client was deleted 63/210163/6
authorInHong Han <inhong1.han@samsung.com>
Thu, 18 Jul 2019 01:23:21 +0000 (10:23 +0900)
committerInHong Han <inhong1.han@samsung.com>
Thu, 18 Jul 2019 01:39:21 +0000 (10:39 +0900)
Change-Id: I3080f943e032c629170659bac5022f81b9385081

src/e_mod_input_panel.c

index ca92416..d6cb774 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;
 
@@ -319,10 +320,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)
@@ -344,6 +343,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);
 }
 
@@ -761,6 +761,18 @@ end:
 }
 
 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)
 {
    E_Client *ec;
@@ -948,6 +960,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,
@@ -958,6 +972,8 @@ _e_input_panel_cb_surface_get(struct wl_client *client, struct wl_resource *reso
       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);
+
    // base_output_resolution.
    e_client_base_output_resolution_update(ec);
 }