window_tracker: Keep the D-Bus filter minimal 69/305269/1 accepted/tizen/8.0/unified/20240202.165934
authorArtur Świgoń <a.swigon@samsung.com>
Tue, 30 Jan 2024 11:19:15 +0000 (12:19 +0100)
committerArtur Świgoń <a.swigon@samsung.com>
Tue, 30 Jan 2024 11:25:33 +0000 (11:25 +0000)
Do not re-enter D-Bus from inside the D-Bus filter.

Change-Id: Ib8f0757e295c0f7eb79dbce7e8cf930fbd43099c

include/window_info.h
src/window_tracker.c

index a12ad9d37c15fd11aaafd21cfe640c1ba59f03a6..acaf89558a2367f9a093c15f091f802e8385c8d7 100644 (file)
@@ -17,6 +17,7 @@ typedef struct {
        Eina_Bool view_change_need; /* Would be not necessary, keep this for later usage */
        WindowActivateInfoType window_activate_info_type;
        uint32_t resource_id;
+       Eina_Bool defunct;
 } WindowInfo;
 
 #endif
index e2aa7c4155b89992d0b8190d8f7685d25e3578a5..aeffc04be5baf94ec4932f1621da7d6bee5a4430 100644 (file)
@@ -91,7 +91,7 @@ fail_con:
 
 static Eina_Bool _window_need_to_be_purged(WindowInfo *wi)
 {
-       if (!wi->window || object_has_defunct_state(wi->window)) {
+       if (!wi->window || wi->defunct || object_has_defunct_state(wi->window)) {
                DEBUG("purging %p because of defunct state or window doesn't exist", wi->window);
                return EINA_TRUE;
        }
@@ -412,31 +412,20 @@ static void _active_window_append(WindowTrackerData *wtd)
 static void
 _remove_window_under_bus(WindowTrackerData *wtd, const char *bus)
 {
+       // We're called from a D-Bus filter, so let's only set a flag in order not to re-enter D-Bus.
        DEBUG("START");
-       Eina_List *window_list = NULL;
        Eina_List *l;
        WindowInfo *wi;
        gchar *bus_name = NULL;
-       AtspiAccessible *window;
 
        EINA_LIST_FOREACH(wtd->window_infos, l, wi) {
                if (!wi) continue;
-               bus_name = atspi_accessible_get_bus_name(wi->window, NULL);
-               if (is_same_str(bus, bus_name)) {
-                       /* We need to call g_object_ref(), becasue window can be disposed in _window_remove()
-                          if it is called at this function. We can check it is disposed by following lines.
-                             g_object_add_weak_pointer (G_OBJECT(window), (gpointer *)&window);
-                             g_object_unref(window);
-                             DEBUG("%p", window); // this shows (nil) */
-                       window_list = eina_list_append(window_list, g_object_ref(wi->window));
-               }
+               bus_name = atspi_accessible_get_bus_name(wi->window, NULL); // No D-Bus call
+               if (is_same_str(bus, bus_name))
+                       wi->defunct = EINA_TRUE;
                g_free(bus_name);
        }
 
-       EINA_LIST_FREE(window_list, window) {
-               _window_remove(wtd, window);
-               g_object_unref(window);
-       }
        DEBUG("END");
 }
 
@@ -702,5 +691,3 @@ AtspiAccessible* window_tracker_top_win_get(WindowTrackerData *wtd)
 {
        return wtd ? wtd->top_win : NULL;
 }
-
-