[tracker/wip/carlosg/portal-initialization] portal: Fix initialization order




commit f3a8012056989f993e936af1ee350abb2eb90825
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Oct 4 12:24:20 2020 +0200

    portal: Fix initialization order
    
    The portal is currently first claiming the bus name, then adding
    the portal object+interface. This may break things with autostart
    as clients are able to send a message to an object path that is not
    there yet.
    
    Changing the order means the object path is there when the DBus name
    is made known, so clients are able to talk immediately to it.

 src/portal/tracker-main.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/src/portal/tracker-main.c b/src/portal/tracker-main.c
index e8977fc4b..8c0429c76 100644
--- a/src/portal/tracker-main.c
+++ b/src/portal/tracker-main.c
@@ -76,7 +76,6 @@ name_acquired_callback (GDBusConnection *connection,
                         gpointer         user_data)
 {
        g_debug ("Name '%s' acquired", name);
-       g_main_loop_quit (user_data);
 }
 
 static void
@@ -123,23 +122,20 @@ main (int argc, char *argv[])
                return EXIT_FAILURE;
        }
 
-       main_loop = g_main_loop_new (NULL, FALSE);
+       portal = tracker_portal_new (connection, NULL, &error);
+       if (!portal) {
+               g_printerr ("%s", error->message);
+               return EXIT_FAILURE;
+       }
 
        g_bus_own_name_on_connection (connection,
                                      "org.freedesktop.portal.Tracker",
                                      G_BUS_NAME_OWNER_FLAGS_NONE,
                                      name_acquired_callback,
                                      name_lost_callback,
-                                     g_main_loop_ref (main_loop),
-                                     (GDestroyNotify) g_main_loop_unref);
+                                     NULL, NULL);
 
-       g_main_loop_run (main_loop);
-
-       portal = tracker_portal_new (connection, NULL, &error);
-       if (!portal) {
-               g_printerr ("%s", error->message);
-               return EXIT_FAILURE;
-       }
+       main_loop = g_main_loop_new (NULL, FALSE);
 
        g_unix_signal_add (SIGINT, sigterm_cb, main_loop);
        g_unix_signal_add (SIGTERM, sigterm_cb, main_loop);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]