Fixed bug 3950 - Don't always call dbus_shutdown in SDL_DBus
authorSam Lantinga <slouken@libsdl.org>
Tue, 13 Feb 2018 08:07:52 -0800
changeset 118685ec7bc5b3d12
parent 11867 4e7f7e186d27
child 11869 68864895c386
Fixed bug 3950 - Don't always call dbus_shutdown in SDL_DBus

Alexander Larsson

dbus_shutdown() is a debug feature which closes all global resources in the dbus library. Calling this should be done by the app, not a library, because if there are multiple users of dbus in the process then SDL could shut it down even though another part is using it.

For example, i had an issue with this in mGBA, which uses both Qt and SDL, both using libdbus. I had a session bus, but no system bus (this was in a flatpak sandbox), and when SDL_DBus_Init() failed to init the system bus it called dbus_shudown() and continued on. This caused issues for Qt when running due to its session bus connections having disappeared beneath it.
src/core/linux/SDL_dbus.c
     1.1 --- a/src/core/linux/SDL_dbus.c	Tue Feb 13 07:59:45 2018 -0800
     1.2 +++ b/src/core/linux/SDL_dbus.c	Tue Feb 13 08:07:52 2018 -0800
     1.3 @@ -139,9 +139,14 @@
     1.4          dbus.connection_close(dbus.session_conn);
     1.5          dbus.connection_unref(dbus.session_conn);
     1.6      }
     1.7 +/* Don't do this - bug 3950
     1.8 +   dbus_shutdown() is a debug feature which closes all global resources in the dbus library. Calling this should be done by the app, not a library, because if there are multiple users of dbus in the process then SDL could shut it down even though another part is using it.
     1.9 +*/
    1.10 +#if 0
    1.11      if (dbus.shutdown) {
    1.12          dbus.shutdown();
    1.13      }
    1.14 +#endif
    1.15      SDL_zero(dbus);
    1.16      UnloadDBUSLibrary();
    1.17  }