e_comp_wl_data: Code clean 50/318050/2
authorJunkyeong Kim <jk0430.kim@samsung.com>
Mon, 23 Sep 2024 10:02:40 +0000 (19:02 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Tue, 24 Sep 2024 04:39:12 +0000 (04:39 +0000)
Check null drag_source and offer_res ahead.

Change-Id: Iade6f1f0738946b8fa1cbc72fd3aef43fe178080

src/bin/server/e_comp_wl_data.c

index 9383a7a..a0b5d33 100644 (file)
@@ -1337,44 +1337,40 @@ e_comp_wl_data_device_send_enter(E_Client *ec)
    uint32_t serial;
    int x, y;
    E_Comp_Config *comp_conf;
-   E_Comp_Wl_Data_Offer *offer;
+   E_Comp_Wl_Data_Offer *offer, *old_offer;
    E_Comp_Wl_Data *comp_wl;
+   E_Comp_Wl_Data_Source *drag_source;
+
 
    struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
    if (!surface) return;
 
    data_device_res =
        e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
-
    if (!data_device_res) return;
-   offer_res = e_comp_wl_data_device_send_offer(ec);
 
    comp_wl = e_comp_wl_get();
-   if (comp_wl->drag_source)
-     {
-        E_Comp_Wl_Data_Source *drag_source = comp_wl->drag_source;
-        E_Comp_Wl_Data_Offer *new_offer;
-        E_Comp_Wl_Data_Offer *old_offer = comp_wl->drag_offer;
+   if (!comp_wl || !comp_wl->drag_source) return;
 
-        if (!offer_res) return;
+   offer_res = e_comp_wl_data_device_send_offer(ec);
+   if (!offer_res) return;
 
-        if (old_offer &&
-            (old_offer->source == drag_source))
-          {
-             old_offer->dropped = EINA_FALSE;
-             old_offer->source = NULL;
-          }
-        drag_source->accepted = EINA_FALSE;
+   drag_source = comp_wl->drag_source;
+   old_offer = comp_wl->drag_offer;
 
-        new_offer = wl_resource_get_user_data(offer_res);
-        comp_wl->drag_offer = new_offer;
-        if (new_offer)
-          {
-             _e_comp_wl_data_offer_update_action(new_offer);
-             if (wl_resource_get_version(offer_res) >= WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION)
-               wl_data_offer_send_source_actions(offer_res, new_offer->source->dnd_actions);
-          }
+   if (old_offer && (old_offer->source == drag_source))
+     {
+        old_offer->dropped = EINA_FALSE;
+        old_offer->source = NULL;
      }
+   drag_source->accepted = EINA_FALSE;
+
+   offer = wl_resource_get_user_data(offer_res);
+   comp_wl->drag_offer = offer;
+
+   _e_comp_wl_data_offer_update_action(offer);
+   if (wl_resource_get_version(offer_res) >= WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION)
+     wl_data_offer_send_source_actions(offer_res, offer->source->dnd_actions);
 
    comp_wl->selection.target = ec;
    offer = wl_resource_get_user_data(offer_res);