[Commits] SDL: linux: Make system D-Bus connection available (in addition ...

libsdl.org revision control commits-owner at libsdl.org
Sun May 28 04:14:25 PDT 2017


details:   https://hg.libsdl.org/SDL/rev/5aebcca5ff18
changeset: 11041:5aebcca5ff18
user:      Ryan C. Gordon <icculus at icculus.org>
date:      Sun May 28 07:08:10 2017 -0400
description:
linux: Make system D-Bus connection available (in addition to session).

diffstat:

 src/core/linux/SDL_dbus.c |  17 ++++++++++++-----
 src/core/linux/SDL_dbus.h |   1 +
 2 files changed, 13 insertions(+), 5 deletions(-)

diffs (54 lines):

diff -r 8ff2f9651a0e -r 5aebcca5ff18 src/core/linux/SDL_dbus.c
--- a/src/core/linux/SDL_dbus.c	Sun May 28 00:41:55 2017 -0400
+++ b/src/core/linux/SDL_dbus.c	Sun May 28 07:08:10 2017 -0400
@@ -112,14 +112,15 @@
         DBusError err;
         dbus.error_init(&err);
         dbus.session_conn = dbus.bus_get_private(DBUS_BUS_SESSION, &err);
+        if (!dbus.error_is_set(&err)) {
+            dbus.system_conn = dbus.bus_get_private(DBUS_BUS_SYSTEM, &err);
+        }
         if (dbus.error_is_set(&err)) {
             dbus.error_free(&err);
-            if (dbus.session_conn) {
-                dbus.connection_unref(dbus.session_conn);
-                dbus.session_conn = NULL;
-            }
+            SDL_DBus_Quit();
             return;  /* oh well */
         }
+        dbus.connection_set_exit_on_disconnect(dbus.system_conn, 0);
         dbus.connection_set_exit_on_disconnect(dbus.session_conn, 0);
     }
 }
@@ -127,12 +128,18 @@
 void
 SDL_DBus_Quit(void)
 {
+    if (dbus.system_conn) {
+        dbus.connection_close(dbus.system_conn);
+        dbus.connection_unref(dbus.system_conn);
+    }
     if (dbus.session_conn) {
         dbus.connection_close(dbus.session_conn);
         dbus.connection_unref(dbus.session_conn);
+    }
+    if (dbus.shutdown) {
         dbus.shutdown();
-        SDL_memset(&dbus, 0, sizeof(dbus));
     }
+    SDL_zero(dbus);
     UnloadDBUSLibrary();
 }
 
diff -r 8ff2f9651a0e -r 5aebcca5ff18 src/core/linux/SDL_dbus.h
--- a/src/core/linux/SDL_dbus.h	Sun May 28 00:41:55 2017 -0400
+++ b/src/core/linux/SDL_dbus.h	Sun May 28 07:08:10 2017 -0400
@@ -32,6 +32,7 @@
 
 typedef struct SDL_DBusContext {
     DBusConnection *session_conn;
+    DBusConnection *system_conn;
 
     DBusConnection *(*bus_get_private)(DBusBusType, DBusError *);
     dbus_bool_t (*bus_register)(DBusConnection *, DBusError *);


More information about the commits mailing list