[Xfce4-commits] [xfce/xfce4-settings] 01/02: xfsettingsd: dbus connection needs setup with g_main and listen for NameLost

noreply at xfce.org noreply at xfce.org
Tue Jun 19 11:51:47 CEST 2018


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       x   f   c   e   -   4   .   1   2   
   in repository xfce/xfce4-settings.

commit 89f26ff5c3ea4d7e0dbe2764c5c6eae48e0a30f5
Author: Jason Zaman <jason at perfinion.com>
Date:   Sat May 5 15:52:54 2018 +0800

    xfsettingsd: dbus connection needs setup with g_main and listen for NameLost
    
    Without calling dbus_connection_setup_with_g_main, no dbus events get
    processed. causing xfsettingsd --replace to not work leaving many old
    xfsettingsd around.
    
    Also the signal NameLost gets sent instead of NameOwnerChanged so listen
    for both now.
    
    Signed-off-by: Jason Zaman <jason at perfinion.com>
    Signed-off-by: Sean Davis <smd.seandavis at gmail.com>
---
 xfsettingsd/main.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/xfsettingsd/main.c b/xfsettingsd/main.c
index f2f1f2c..4c144fa 100644
--- a/xfsettingsd/main.c
+++ b/xfsettingsd/main.c
@@ -38,6 +38,7 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 #include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
 
 #ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
@@ -119,6 +120,21 @@ dbus_connection_filter_func (DBusConnection *connection,
         }
     }
 
+    if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameLost"))
+    {
+        if (dbus_message_get_args (message, NULL,
+                                   DBUS_TYPE_STRING, &name,
+                                   DBUS_TYPE_INVALID))
+        {
+            if (g_strcmp0 (name, XFSETTINGS_DBUS_NAME) == 0)
+            {
+                g_printerr (G_LOG_DOMAIN ": %s\n", "Another instance took over. Leaving...");
+                gtk_main_quit ();
+                return DBUS_HANDLER_RESULT_HANDLED;
+            }
+        }
+    }
+
     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
@@ -241,6 +257,7 @@ main (gint argc, gchar **argv)
     dbus_connection = dbus_bus_get (DBUS_BUS_SESSION, NULL);
     if (G_LIKELY (dbus_connection != NULL))
     {
+        dbus_connection_setup_with_g_main (dbus_connection, NULL);
         dbus_connection_set_exit_on_disconnect (dbus_connection, FALSE);
 
         dbus_flags = DBUS_NAME_FLAG_ALLOW_REPLACEMENT | DBUS_NAME_FLAG_DO_NOT_QUEUE;
@@ -255,7 +272,12 @@ main (gint argc, gchar **argv)
             return EXIT_SUCCESS;
         }
 
-        dbus_bus_add_match (dbus_connection, "type='signal',member='NameOwnerChanged',arg0='"XFSETTINGS_DBUS_NAME"'", NULL);
+        dbus_bus_add_match (dbus_connection,
+            "type='signal',interface='"DBUS_INTERFACE_DBUS"',member='NameOwnerChanged',arg0='"XFSETTINGS_DBUS_NAME"'",
+            NULL);
+        dbus_bus_add_match (dbus_connection,
+            "type='signal',interface='"DBUS_INTERFACE_DBUS"',member='NameLost',arg0='"XFSETTINGS_DBUS_NAME"'",
+            NULL);
         dbus_connection_add_filter (dbus_connection, dbus_connection_filter_func, NULL, NULL);
     }
     else

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list