e_input: Add missing unref of input device 41/300641/1
authorInhong Han <inhong1.han@samsung.com>
Mon, 30 Oct 2023 07:46:01 +0000 (16:46 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 30 Oct 2023 10:33:30 +0000 (19:33 +0900)
Change-Id: Ic383a5cff3c3e518031289599b3119a313fe1a27

src/bin/e_input_inputs.c

index 8e1243d949ced505385d91cffa3ad90dc50b4fc6..ffa7646fe7e5f495991e08366a24816cee2da4df 100644 (file)
@@ -324,10 +324,13 @@ _e_input_add_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
 static Eina_Bool
 _e_input_remove_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
 {
+   Eina_Bool ret = EINA_FALSE;
    const Eina_List *dev_list = NULL, *l;
+   const GList *e_dev_list = NULL;
    Eina_List *ll, *ll_next;
    Ecore_Device *dev = NULL, *data;
    const char *identifier;
+   const gchar *device_identifier;
 
    if (!edev->path) return EINA_FALSE;
 
@@ -359,11 +362,45 @@ _e_input_remove_ecore_device(E_Input_Evdev *edev, Ecore_Device_Class clas)
                 }
               _e_input_ecore_device_event(dev, edev->seat ? edev->seat->name : NULL, EINA_FALSE);
               ecore_device_del(dev);
-              return EINA_TRUE;
+              ret = EINA_TRUE;
            }
       }
 
-   return EINA_FALSE;
+   e_dev_list = e_device_list_get();
+   if (!e_dev_list)
+     {
+        ERR("Failed to get e device list");
+        return EINA_FALSE;
+     }
+
+   for (GList *list = g_list_first((GList *)e_dev_list); list; list = list->next)
+     {
+        E_Device *device = (E_Device *)list->data;
+        if (!device) continue;
+        device_identifier = e_device_identifier_get(device);
+        if (!device_identifier) continue;
+
+        if ((e_device_class_get(device) == clas) && (!strcmp(device_identifier, edev->path)))
+          {
+             if (edev->e_dev)
+               {
+                  g_object_unref(device);
+                  edev->e_dev = NULL;
+               }
+             else if (edev->e_dev_list)
+               {
+                  GList *del_list = g_list_find(edev->e_dev_list, device);
+                  if (del_list)
+                    {
+                       g_object_unref(device);
+                       edev->e_dev_list = g_list_delete_link(edev->e_dev_list, del_list);
+                    }
+               }
+             ret = EINA_TRUE;
+          }
+     }
+
+   return ret;
 }
 
 Eina_Bool