|
|
b61949 |
From bcf04c4b6ae1543fd3f0d11b8c0f7907c1a0e14a Mon Sep 17 00:00:00 2001
|
|
|
b61949 |
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
|
|
|
b61949 |
Date: Fri, 1 Jun 2018 17:16:35 +0200
|
|
|
b61949 |
Subject: [PATCH 06/15] libgdm: Don't double-ref the connection got from task
|
|
|
b61949 |
|
|
|
b61949 |
Both if we re-use the shared connection in `gdm_client_get_connection` and if
|
|
|
b61949 |
we create a new one in `on_connected`, we steal the pointer here by using
|
|
|
b61949 |
`g_task_propagate_pointer` and thus we don't have to add an additional
|
|
|
b61949 |
reference to this connection when returning, or it won't ever be consumed by
|
|
|
b61949 |
function customers.
|
|
|
b61949 |
---
|
|
|
b61949 |
libgdm/gdm-client.c | 4 ++--
|
|
|
b61949 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
b61949 |
|
|
|
b61949 |
diff --git a/libgdm/gdm-client.c b/libgdm/gdm-client.c
|
|
|
b61949 |
index fa4ba8426..36292148c 100644
|
|
|
b61949 |
--- a/libgdm/gdm-client.c
|
|
|
b61949 |
+++ b/libgdm/gdm-client.c
|
|
|
b61949 |
@@ -509,76 +509,76 @@ on_got_manager_for_opening_connection (GdmClient *client,
|
|
|
b61949 |
GAsyncResult *result,
|
|
|
b61949 |
GTask *task)
|
|
|
b61949 |
{
|
|
|
b61949 |
GCancellable *cancellable;
|
|
|
b61949 |
GdmManager *manager;
|
|
|
b61949 |
GError *error;
|
|
|
b61949 |
|
|
|
b61949 |
error = NULL;
|
|
|
b61949 |
manager = g_task_propagate_pointer (G_TASK (result), &error);
|
|
|
b61949 |
if (manager == NULL) {
|
|
|
b61949 |
g_task_return_error (task, error);
|
|
|
b61949 |
g_object_unref (task);
|
|
|
b61949 |
return;
|
|
|
b61949 |
}
|
|
|
b61949 |
|
|
|
b61949 |
cancellable = g_task_get_cancellable (task);
|
|
|
b61949 |
gdm_manager_call_open_session (manager,
|
|
|
b61949 |
cancellable,
|
|
|
b61949 |
(GAsyncReadyCallback)
|
|
|
b61949 |
on_session_opened,
|
|
|
b61949 |
task);
|
|
|
b61949 |
|
|
|
b61949 |
g_object_unref (manager);
|
|
|
b61949 |
}
|
|
|
b61949 |
|
|
|
b61949 |
static GDBusConnection *
|
|
|
b61949 |
gdm_client_get_connection_finish (GdmClient *client,
|
|
|
b61949 |
GAsyncResult *result,
|
|
|
b61949 |
GError **error)
|
|
|
b61949 |
{
|
|
|
b61949 |
- GDBusConnection *connection = NULL;
|
|
|
b61949 |
+ GDBusConnection *connection;
|
|
|
b61949 |
|
|
|
b61949 |
g_return_val_if_fail (GDM_IS_CLIENT (client), FALSE);
|
|
|
b61949 |
|
|
|
b61949 |
connection = g_task_propagate_pointer (G_TASK (result), error);
|
|
|
b61949 |
if (connection == NULL) {
|
|
|
b61949 |
return NULL;
|
|
|
b61949 |
}
|
|
|
b61949 |
|
|
|
b61949 |
if (client->priv->connection == NULL) {
|
|
|
b61949 |
client->priv->connection = connection;
|
|
|
b61949 |
g_object_add_weak_pointer (G_OBJECT (client->priv->connection),
|
|
|
b61949 |
(gpointer *) &client->priv->connection);
|
|
|
b61949 |
}
|
|
|
b61949 |
|
|
|
b61949 |
- return g_object_ref (connection);
|
|
|
b61949 |
+ return connection;
|
|
|
b61949 |
}
|
|
|
b61949 |
|
|
|
b61949 |
static void
|
|
|
b61949 |
gdm_client_get_connection (GdmClient *client,
|
|
|
b61949 |
GCancellable *cancellable,
|
|
|
b61949 |
GAsyncReadyCallback callback,
|
|
|
b61949 |
gpointer user_data)
|
|
|
b61949 |
{
|
|
|
b61949 |
GTask *task;
|
|
|
b61949 |
|
|
|
b61949 |
g_return_if_fail (GDM_IS_CLIENT (client));
|
|
|
b61949 |
|
|
|
b61949 |
task = g_task_new (G_OBJECT (client),
|
|
|
b61949 |
cancellable,
|
|
|
b61949 |
callback,
|
|
|
b61949 |
user_data);
|
|
|
b61949 |
|
|
|
b61949 |
if (client->priv->connection != NULL) {
|
|
|
b61949 |
g_task_return_pointer (task,
|
|
|
b61949 |
g_object_ref (client->priv->connection),
|
|
|
b61949 |
(GDestroyNotify) g_object_unref);
|
|
|
b61949 |
g_object_unref (task);
|
|
|
b61949 |
return;
|
|
|
b61949 |
}
|
|
|
b61949 |
|
|
|
b61949 |
get_manager (client,
|
|
|
b61949 |
cancellable,
|
|
|
b61949 |
(GAsyncReadyCallback)
|
|
|
b61949 |
on_got_manager_for_opening_connection,
|
|
|
b61949 |
task);
|
|
|
b61949 |
--
|
|
|
b61949 |
2.26.2
|
|
|
b61949 |
|