Commit c67fe0fd authored by Marco Trevisan's avatar Marco Trevisan 🎺

libgdm: Reinitialize connection when manager is disposed

The GdmManager gets disposed while the connection might be disposed later since
it's referenced by proxies. Thus when recreating the manager instance the
connection is not re-initialized and thus won't be valid anymore, making
impossible to login with with another UID.
parent b3224275
......@@ -91,6 +91,12 @@ on_got_manager (GdmManager *manager,
if (client->priv->manager == NULL) {
client->priv->manager = new_manager;
if (client->priv->connection != NULL) {
g_object_remove_weak_pointer (G_OBJECT (client->priv->connection),
(gpointer *)
&client->priv->connection);
client->priv->connection = NULL;
}
} else {
g_object_ref (client->priv->manager);
g_object_unref (new_manager);
......@@ -412,6 +418,24 @@ on_got_manager_for_reauthentication (GdmClient *client,
}
static void
on_manager_destroyed (gpointer data,
GObject *disposed_manager)
{
GdmClient *client = data;
if (client->priv->connection != NULL) {
g_object_remove_weak_pointer (G_OBJECT (client->priv->connection),
(gpointer *)
&client->priv->connection);
client->priv->connection = NULL;
}
if (client->priv->manager == (GdmManager *) disposed_manager) {
client->priv->manager = NULL;
}
}
static gboolean
gdm_client_open_connection_sync (GdmClient *client,
GCancellable *cancellable,
......@@ -429,6 +453,13 @@ gdm_client_open_connection_sync (GdmClient *client,
cancellable,
error);
if (client->priv->connection != NULL) {
g_object_remove_weak_pointer (G_OBJECT (client->priv->connection),
(gpointer *)
&client->priv->connection);
client->priv->connection = NULL;
}
if (client->priv->manager == NULL) {
goto out;
}
......@@ -461,6 +492,8 @@ gdm_client_open_connection_sync (GdmClient *client,
goto out;
}
g_object_weak_ref (G_OBJECT (client->priv->manager),
on_manager_destroyed, client);
g_object_add_weak_pointer (G_OBJECT (client->priv->connection),
(gpointer *)
&client->priv->connection);
......@@ -1622,6 +1655,11 @@ gdm_client_finalize (GObject *object)
&client->priv->chooser);
}
if (client->priv->manager != NULL) {
g_object_weak_unref (G_OBJECT (client->priv->manager),
on_manager_destroyed, client);
}
if (client->priv->connection != NULL) {
g_object_remove_weak_pointer (G_OBJECT (client->priv->connection),
(gpointer *)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment