gdbus: Use object manager only if callback functions are set

This commit is contained in:
Marcel Holtmann 2012-12-27 21:30:06 -08:00
parent 91e3369a38
commit 9ba681ddcd
1 changed files with 7 additions and 8 deletions

View File

@ -871,15 +871,13 @@ static void get_managed_objects_reply(DBusPendingCall *call, void *user_data)
done:
dbus_message_unref(reply);
dbus_pending_call_unref(client->pending_call);
client->pending_call = NULL;
g_dbus_client_unref(client);
}
static void get_managed_objects(GDBusClient *client)
{
DBusMessage *msg;
DBusPendingCall *call;
msg = dbus_message_new_method_call(client->service_name, "/",
DBUS_INTERFACE_DBUS ".ObjectManager",
@ -890,15 +888,16 @@ static void get_managed_objects(GDBusClient *client)
dbus_message_append_args(msg, DBUS_TYPE_INVALID);
if (dbus_connection_send_with_reply(client->dbus_conn, msg,
&client->pending_call, -1) == FALSE) {
&call, -1) == FALSE) {
dbus_message_unref(msg);
return;
}
g_dbus_client_ref(client);
dbus_pending_call_set_notify(client->pending_call,
get_managed_objects_reply, client, NULL);
dbus_pending_call_set_notify(call, get_managed_objects_reply,
client, NULL);
dbus_pending_call_unref(call);
dbus_message_unref(msg);
}
@ -935,8 +934,6 @@ done:
dbus_pending_call_unref(client->pending_call);
client->pending_call = NULL;
get_managed_objects(client);
g_dbus_client_unref(client);
}
@ -1220,5 +1217,7 @@ gboolean g_dbus_client_set_proxy_handlers(GDBusClient *client,
client->property_changed = property_changed;
client->user_data = user_data;
get_managed_objects(client);
return TRUE;
}