After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 674717 - g_dbus_connection_register_object can return 0 and a NULL error
g_dbus_connection_register_object can return 0 and a NULL error
Status: RESOLVED NOTABUG
Product: glib
Classification: Platform
Component: gdbus
unspecified
Other Linux
: Normal normal
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-04-24 12:52 UTC by Daniele Forsi
Modified: 2012-04-24 14:23 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Daniele Forsi 2012-04-24 12:52:46 UTC
g_dbus_connection_register_object() will return 0 and a NULL error when one of the tests at its beginning fails:

  g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), 0);
  g_return_val_if_fail (object_path != NULL && g_variant_is_object_path (object_path), 0);
  g_return_val_if_fail (interface_info != NULL, 0);
  g_return_val_if_fail (g_dbus_is_interface_name (interface_info->name), 0);

  g_return_val_if_fail (check_initialized (connection), 0);

But the documentation states:
 * Returns: 0 if @error is set, otherwise a registration id (never 0)
 * that can be used with g_dbus_connection_unregister_object()
Comment 1 David Zeuthen (not reading bugmail) 2012-04-24 14:23:25 UTC
If one of these tests fail, it means you are using the API incorrectly and a warning is printed on stderr.

In this case (a so-called programmer error), it is customary and intentional to not set the GError - you will see the same behavior all over GLib. And it is even spelled out in the docs that GError should only be used for recoverable run-time errors, not programmer errors

 http://developer.gnome.org/glib/unstable/glib-Error-Reporting.html#glib-Error-Reporting.description