Conversation
see GNOME/gnome-power-manager@7568769f for a reference, though this is not a 1:1 copy
|
|
||
| error = NULL; | ||
| if (!gpm_manager_register_dbus (manager, session_connection, &error)) { | ||
| g_error ("Failed to export D-Bus objects: %s", error->message); |
There was a problem hiding this comment.
g_error causes a core dump, this should be g_warning
| !gpm_backlight_register_dbus (manager->priv->backlight, connection, error)) | ||
| return FALSE; | ||
|
|
||
| if (manager->priv->kbd_backlight != NULL) { | ||
| gpm_kbd_backlight_register_dbus (manager->priv->kbd_backlight, connection, error); |
There was a problem hiding this comment.
These two functions (*_register_dbus) seem and behave somewhat similarly, but one returns void and the other gboolean, which means these two conditional blocks behave differently.
| dbus_g_proxy_call_no_reply (nm_proxy, "sleep", G_TYPE_INVALID); | ||
|
|
||
| result = g_dbus_proxy_call_sync (nm_proxy, |
There was a problem hiding this comment.
dbus_g_proxy_call_no_reply is async, but you're replacing it with the sync variant. You should use g_dbus_proxy_call.
| dbus_g_proxy_call_no_reply (nm_proxy, "wake", G_TYPE_INVALID); | ||
|
|
||
| result = g_dbus_proxy_call_sync (nm_proxy, |
There was a problem hiding this comment.
dbus_g_proxy_call_no_reply is async, but you're replacing it with the sync variant. You should use g_dbus_proxy_call.
| dbus_g_proxy_call_no_reply (screensaver->priv->proxy, | ||
| "Lock", G_TYPE_INVALID); | ||
| result = g_dbus_proxy_call_sync (screensaver->priv->proxy, |
There was a problem hiding this comment.
dbus_g_proxy_call_no_reply is async, but you're replacing it with the sync variant. You should use g_dbus_proxy_call.
| dbus_g_proxy_call_no_reply (screensaver->priv->proxy, | ||
| "SimulateUserActivity", | ||
| G_TYPE_INVALID); | ||
| result = g_dbus_proxy_call_sync (screensaver->priv->proxy, |
There was a problem hiding this comment.
dbus_g_proxy_call_no_reply is async, but you're replacing it with the sync variant. You should use g_dbus_proxy_call.
| gpm_kbd_backlight_register_dbus (GpmKbdBacklight *backlight, | ||
| GDBusConnection *connection, | ||
| GError **error) | ||
| { | ||
| GDBusNodeInfo *node_info; | ||
|
|
||
| g_return_if_fail (GPM_IS_KBD_BACKLIGHT (backlight)); | ||
| g_return_if_fail (G_IS_DBUS_CONNECTION (connection)); | ||
|
|
||
| if (backlight->priv->bus_connection != NULL) | ||
| return; | ||
|
|
||
| node_info = g_dbus_node_info_new_for_xml (gpm_kbd_backlight_introspection_xml, error); | ||
| if (node_info == NULL) | ||
| return; | ||
|
|
||
| backlight->priv->bus_object_id = | ||
| g_dbus_connection_register_object (connection, | ||
| GPM_DBUS_PATH_KBD_BACKLIGHT, | ||
| node_info->interfaces[0], | ||
| &gpm_kbd_backlight_interface_vtable, | ||
| backlight, | ||
| NULL, | ||
| error); | ||
| g_dbus_node_info_unref (node_info); | ||
|
|
||
| if (backlight->priv->bus_object_id == 0) | ||
| return; | ||
|
|
||
| backlight->priv->bus_connection = g_object_ref (connection); | ||
| } |
There was a problem hiding this comment.
nitpick: This entire function has some strange indentation issues
| dbus_g_error_domain_register (GPM_MANAGER_ERROR, NULL, GPM_MANAGER_TYPE_ERROR); | ||
| dbus_g_connection_register_g_object (connection, GPM_DBUS_PATH, object); | ||
| if (gpm_manager_node_info == NULL) { | ||
| gpm_manager_node_info = g_dbus_node_info_new_for_xml (gpm_manager_introspection_xml, &error); |
There was a problem hiding this comment.
This should be freed with g_dbus_node_info_unref, but since gpm_manager_node_info is a global static, it should probably be freed on process exit.
| GS_LISTENER_PATH, | ||
| GS_LISTENER_INTERFACE); | ||
| screensaver->priv->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, | ||
| G_DBUS_PROXY_FLAGS_NONE, |
There was a problem hiding this comment.
GNOME uses G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS for these, not sure if it's better or not, but it seems like GNOME's version does fewer things. This might be related to the sync calls, so not sure.
see GNOME/gnome-power-manager@7568769f for a reference, though this is not a 1:1 copy
please test thoroughly as I can not test it on real hardware right now.