Reduce duplicate code to check input method 26/276826/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 27 Jun 2022 04:29:56 +0000 (13:29 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 28 Jun 2022 00:41:13 +0000 (09:41 +0900)
Change-Id: I4d8737bb04d42babcc9c07d476ab96c50fba74f9
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/e_mod_main.c

index 724602d..ce354b5 100644 (file)
@@ -1244,13 +1244,7 @@ _e_text_input_cb_deactivate(struct wl_client *client EINA_UNUSED, struct wl_reso
    if (g_input_method && g_input_method->resource)
      input_method = wl_resource_get_user_data(g_input_method->resource);
 
-   if (!input_method)
-     {
-        WTI_WARNING(seat,
-                    WL_DISPLAY_ERROR_INVALID_OBJECT,
-                    "No Input Method For Seat");
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(input_method);
 
    _e_text_input_deactivate(text_input, input_method, EINA_TRUE);
 }
@@ -1875,13 +1869,7 @@ _e_text_input_cb_destroy(struct wl_client *client, struct wl_resource *resource)
    if (g_input_method && g_input_method->resource)
      input_method = wl_resource_get_user_data(g_input_method->resource);
 
-   if (!input_method)
-     {
-        WTI_WARNING(resource,
-                    WL_DISPLAY_ERROR_INVALID_OBJECT,
-                    "No Input Method For Seat");
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(input_method);
 
    LOGI("text_input(%p), focus(%d), input_method(%p), input_method->resource(%p), context(%p), context->resource(%p), resource(%p)",
         text_input, (text_input == g_text_input), input_method, input_method->resource, input_method->context,
@@ -1939,13 +1927,7 @@ _e_text_input_manager_cb_text_input_create(struct wl_client *client, struct wl_r
    E_Text_Input_Mgr *text_input_mgr = wl_resource_get_user_data(resource);
    E_Text_Input *text_input = NULL;
 
-   if (!text_input_mgr)
-     {
-        WTI_WARNING(resource,
-                    WL_DISPLAY_ERROR_INVALID_OBJECT,
-                    "No Text Input Manager For Resource");
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(text_input_mgr);
 
    if (!(text_input = E_NEW(E_Text_Input, 1)))
      {
@@ -1995,14 +1977,7 @@ _e_text_input_method_cb_unbind(struct wl_resource *resource)
 {
    LOGI("");
    E_Input_Method *input_method = wl_resource_get_user_data(resource);
-
-   if (!input_method)
-     {
-        WTI_WARNING(resource,
-                    WL_DISPLAY_ERROR_INVALID_OBJECT,
-                    "No Input Method For Resource");
-        return;
-     }
+   EINA_SAFETY_ON_NULL_RETURN(input_method);
 
    if (input_method->resource != resource) return;