From 1d4f1675480769618a5595e40c6b459145676ac1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Fri, 1 Jun 2018 17:07:41 +0200
Subject: [PATCH 05/15] libgdm: Unref the manager propagated from task
This instance has already been reffed when passed to the task, and since
we're stealing it with `g_task_propagate_pointer` it won't be unreffed.
We could also do this in the `on_reauthentication_channel_opened` callback
but since the new task will ref it anyway, we can just be clean and do it
here.
---
libgdm/gdm-client.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libgdm/gdm-client.c b/libgdm/gdm-client.c
index f327344ec..fa4ba8426 100644
--- a/libgdm/gdm-client.c
+++ b/libgdm/gdm-client.c
@@ -363,61 +363,61 @@ on_reauthentication_channel_opened (GdmManager *manager,
on_reauthentication_channel_connected,
task);
}
static void
on_got_manager_for_reauthentication (GdmClient *client,
GAsyncResult *result,
GTask *task)
{
GCancellable *cancellable;
GdmManager *manager;
char *username;
GError *error;
error = NULL;
manager = g_task_propagate_pointer (G_TASK (result), &error);
if (manager == NULL) {
g_task_return_error (task, error);
g_object_unref (task);
return;
}
cancellable = g_task_get_cancellable (task);
username = g_object_get_data (G_OBJECT (task), "username");
gdm_manager_call_open_reauthentication_channel (manager,
username,
cancellable,
(GAsyncReadyCallback)
on_reauthentication_channel_opened,
task);
-
+ g_object_unref (manager);
}
static GDBusConnection *
gdm_client_get_connection_sync (GdmClient *client,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GdmManager) manager = NULL;
gboolean ret;
g_return_val_if_fail (GDM_IS_CLIENT (client), FALSE);
if (client->priv->connection != NULL) {
return g_object_ref (client->priv->connection);
}
manager = gdm_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
"org.gnome.DisplayManager",
"/org/gnome/DisplayManager/Manager",
cancellable,
error);
if (manager == NULL) {
goto out;
}
ret = gdm_manager_call_open_session_sync (manager,
&client->priv->address,
cancellable,
@@ -500,60 +500,62 @@ on_session_opened (GdmManager *manager,
cancellable,
(GAsyncReadyCallback)
on_connected,
task);
g_object_unref (client);
}
static void
on_got_manager_for_opening_connection (GdmClient *client,
GAsyncResult *result,
GTask *task)
{
GCancellable *cancellable;
GdmManager *manager;
GError *error;
error = NULL;
manager = g_task_propagate_pointer (G_TASK (result), &error);
if (manager == NULL) {
g_task_return_error (task, error);
g_object_unref (task);
return;
}
cancellable = g_task_get_cancellable (task);
gdm_manager_call_open_session (manager,
cancellable,
(GAsyncReadyCallback)
on_session_opened,
task);
+
+ g_object_unref (manager);
}
static GDBusConnection *
gdm_client_get_connection_finish (GdmClient *client,
GAsyncResult *result,
GError **error)
{
GDBusConnection *connection = NULL;
g_return_val_if_fail (GDM_IS_CLIENT (client), FALSE);
connection = g_task_propagate_pointer (G_TASK (result), error);
if (connection == NULL) {
return NULL;
}
if (client->priv->connection == NULL) {
client->priv->connection = connection;
g_object_add_weak_pointer (G_OBJECT (client->priv->connection),
(gpointer *) &client->priv->connection);
}
return g_object_ref (connection);
}
static void
gdm_client_get_connection (GdmClient *client,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
--
2.26.2