From a27a18bbc583ef8095cd73d9571a6bf7af7140a3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sun, 4 Oct 2020 12:24:20 +0200 Subject: 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. Fixes the error reported at https://github.com/flathub/org.gnome.Music/pull/24#issuecomment-702565846 --- 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); -- cgit v1.2.1