[glib/mcatanzaro/gdbus-dir-addresses: 2/7] gdbus: Stop server on dispose



commit 99b580a0b2b6da98ca9563df2309cddde988c005
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Wed Jun 12 13:29:52 2019 -0500

    gdbus: Stop server on dispose
    
    This is not going to have much any effect currently since stop() just
    disconnects a signal handler (that is going to be disconnected in
    finalize anyway) and stops the socket service (that is going to be
    destroyed in finalize), but it makes sense to do here for robustness.

 gio/gdbusserver.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/gio/gdbusserver.c b/gio/gdbusserver.c
index 2f137ecca..1bdb8260c 100644
--- a/gio/gdbusserver.c
+++ b/gio/gdbusserver.c
@@ -161,6 +161,17 @@ static void initable_iface_init       (GInitableIface *initable_iface);
 G_DEFINE_TYPE_WITH_CODE (GDBusServer, g_dbus_server, G_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, initable_iface_init))
 
+static void
+g_dbus_server_dispose (GObject *object)
+{
+  GDBusServer *server = G_DBUS_SERVER (object);
+
+  if (server->active)
+    g_dbus_server_stop (server);
+
+  G_OBJECT_CLASS (g_dbus_server_parent_class)->dispose (object);
+}
+
 static void
 g_dbus_server_finalize (GObject *object)
 {
@@ -270,6 +281,7 @@ g_dbus_server_class_init (GDBusServerClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
+  gobject_class->dispose      = g_dbus_server_dispose;
   gobject_class->finalize     = g_dbus_server_finalize;
   gobject_class->set_property = g_dbus_server_set_property;
   gobject_class->get_property = g_dbus_server_get_property;


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