gdbus: Don't use g_assert_no_error() GDBusObjectManagerServer
authorStef Walter <stefw@redhat.com>
Wed, 5 Aug 2015 11:25:47 +0000 (13:25 +0200)
committerStef Walter <stefw@redhat.com>
Wed, 5 Aug 2015 11:43:08 +0000 (13:43 +0200)
There are real world cases where emitting signals can fail, such
as if the DBus connection closes. Asserting and aborting the process
in these cases is just plain lazy.

Ignore the errors when the connection is closed, and turn the
others into warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=753278

gio/gdbusobjectmanagerserver.c

index bb6f8c2..6745df0 100644 (file)
@@ -30,6 +30,8 @@
 #include "gdbusmethodinvocation.h"
 #include "gdbuserror.h"
 
+#include "gioerror.h"
+
 #include "glibintl.h"
 
 /**
@@ -927,7 +929,11 @@ g_dbus_object_manager_server_emit_interfaces_added (GDBusObjectManagerServer *ma
                                                 object_path,
                                                 &array_builder),
                                  &error);
-  g_assert_no_error (error);
+  if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CLOSED))
+    {
+      g_warning ("Couldn't emit InterfacesAdded signal: %s", error->message);
+      g_error_free (error);
+    }
  out:
   ;
 }
@@ -960,7 +966,11 @@ g_dbus_object_manager_server_emit_interfaces_removed (GDBusObjectManagerServer *
                                                 object_path,
                                                 &array_builder),
                                  &error);
-  g_assert_no_error (error);
+  if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CLOSED))
+    {
+      g_warning ("Couldn't emit InterfacesRemoved signal: %s", error->message);
+      g_error_free (error);
+    }
  out:
   ;
 }