Blame SOURCES/0004-libgdm-Drop-weak-refs-on-the-GDBusConnection.patch

b61949
From 2f3bd5fc3dffd760edd0513c94e8801b36a2bcce Mon Sep 17 00:00:00 2001
b61949
From: Iain Lane <iainl@gnome.org>
b61949
Date: Mon, 14 May 2018 16:32:25 -0400
b61949
Subject: [PATCH 04/15] libgdm: Drop weak refs on the GDBusConnection
b61949
b61949
The GDBusProxies hold a strong reference to the connection themselves,
b61949
so maintaining separate weak references is unnecessary.
b61949
b61949
This commit drops those extraneous weak references.
b61949
b61949
https://bugzilla.gnome.org/show_bug.cgi?id=795940
b61949
---
b61949
 libgdm/gdm-client.c | 47 ---------------------------------------------
b61949
 1 file changed, 47 deletions(-)
b61949
b61949
diff --git a/libgdm/gdm-client.c b/libgdm/gdm-client.c
b61949
index e7b93e382..f327344ec 100644
b61949
--- a/libgdm/gdm-client.c
b61949
+++ b/libgdm/gdm-client.c
b61949
@@ -625,67 +625,60 @@ gdm_client_open_reauthentication_channel_sync (GdmClient     *client,
b61949
                                                                    username,
b61949
                                                                    &address,
b61949
                                                                    cancellable,
b61949
                                                                    error);
b61949
 
b61949
         if (!ret) {
b61949
                 goto out;
b61949
         }
b61949
 
b61949
         g_debug ("GdmClient: connecting to address: %s", client->priv->address);
b61949
 
b61949
         connection = g_dbus_connection_new_for_address_sync (address,
b61949
                                                              G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
b61949
                                                              NULL,
b61949
                                                              cancellable,
b61949
                                                              error);
b61949
 
b61949
         if (connection == NULL) {
b61949
                 g_free (address);
b61949
                 goto out;
b61949
         }
b61949
         g_free (address);
b61949
 
b61949
         user_verifier = gdm_user_verifier_proxy_new_sync (connection,
b61949
                                                           G_DBUS_PROXY_FLAGS_NONE,
b61949
                                                           NULL,
b61949
                                                           SESSION_DBUS_PATH,
b61949
                                                           cancellable,
b61949
                                                           error);
b61949
 
b61949
-        if (user_verifier != NULL) {
b61949
-                g_object_weak_ref (G_OBJECT (user_verifier),
b61949
-                                   (GWeakNotify)
b61949
-                                   g_object_unref,
b61949
-                                   connection);
b61949
-        }
b61949
-
b61949
  out:
b61949
         return user_verifier;
b61949
 }
b61949
 
b61949
 /**
b61949
  * gdm_client_open_reauthentication_channel:
b61949
  * @client: a #GdmClient
b61949
  * @username: user to reauthenticate
b61949
  * @callback: a #GAsyncReadyCallback to call when the request is satisfied
b61949
  * @user_data: The data to pass to @callback
b61949
  * @cancellable: a #GCancellable
b61949
  *
b61949
  * Gets a #GdmUserVerifier object that can be used to
b61949
  * reauthenticate an already logged in user.
b61949
  */
b61949
 void
b61949
 gdm_client_open_reauthentication_channel (GdmClient           *client,
b61949
                                           const char          *username,
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
@@ -736,66 +729,60 @@ gdm_client_open_reauthentication_channel_finish (GdmClient       *client,
b61949
  * Returns: (transfer full): #GdmUserVerifier or %NULL if not connected
b61949
  */
b61949
 GdmUserVerifier *
b61949
 gdm_client_get_user_verifier_sync (GdmClient     *client,
b61949
                                    GCancellable  *cancellable,
b61949
                                    GError       **error)
b61949
 {
b61949
         g_autoptr(GDBusConnection) connection = NULL;
b61949
 
b61949
         if (client->priv->user_verifier != NULL) {
b61949
                 return g_object_ref (client->priv->user_verifier);
b61949
         }
b61949
 
b61949
         connection = gdm_client_get_connection_sync (client, cancellable, error);
b61949
 
b61949
         if (connection == NULL) {
b61949
                 return NULL;
b61949
         }
b61949
 
b61949
         client->priv->user_verifier = gdm_user_verifier_proxy_new_sync (connection,
b61949
                                                                         G_DBUS_PROXY_FLAGS_NONE,
b61949
                                                                         NULL,
b61949
                                                                         SESSION_DBUS_PATH,
b61949
                                                                         cancellable,
b61949
                                                                         error);
b61949
 
b61949
         if (client->priv->user_verifier != NULL) {
b61949
                 g_object_add_weak_pointer (G_OBJECT (client->priv->user_verifier),
b61949
                                            (gpointer *)
b61949
                                            &client->priv->user_verifier);
b61949
-                g_object_ref (connection);
b61949
-                g_object_weak_ref (G_OBJECT (client->priv->user_verifier),
b61949
-                                   (GWeakNotify)
b61949
-                                   g_object_unref,
b61949
-                                   client->priv->connection);
b61949
-
b61949
                 if (client->priv->enabled_extensions != NULL) {
b61949
                         gboolean res;
b61949
 
b61949
                         client->priv->user_verifier_extensions = g_hash_table_new_full (g_str_hash,
b61949
                                                                                         g_str_equal,
b61949
                                                                                         NULL,
b61949
                                                                                         (GDestroyNotify)
b61949
                                                                                         free_interface_skeleton);
b61949
                         res = gdm_user_verifier_call_enable_extensions_sync (client->priv->user_verifier,
b61949
                                                                             (const char * const *)
b61949
                                                                              client->priv->enabled_extensions,
b61949
                                                                              cancellable,
b61949
                                                                              NULL);
b61949
 
b61949
                         if (res) {
b61949
                                 size_t i;
b61949
                                 for (i = 0; client->priv->enabled_extensions[i] != NULL; i++) {
b61949
                                             if (strcmp (client->priv->enabled_extensions[i],
b61949
                                                         gdm_user_verifier_choice_list_interface_info ()->name) == 0) {
b61949
                                                         GdmUserVerifierChoiceList *choice_list_interface;
b61949
                                                         choice_list_interface = gdm_user_verifier_choice_list_proxy_new_sync (client->priv->connection,
b61949
                                                                                                                               G_DBUS_PROXY_FLAGS_NONE,
b61949
                                                                                                                               NULL,
b61949
                                                                                                                               SESSION_DBUS_PATH,
b61949
                                                                                                                               cancellable,
b61949
                                                                                                                               NULL);
b61949
                                                         if (choice_list_interface != NULL)
b61949
                                                                     g_hash_table_insert (client->priv->user_verifier_extensions, client->priv->enabled_extensions[i], choice_list_interface);
b61949
                                             }
b61949
                                 }
b61949
@@ -881,65 +868,60 @@ gdm_client_get_user_verifier (GdmClient           *client,
b61949
  * @result: The #GAsyncResult from the callback
b61949
  * @error: a #GError
b61949
  *
b61949
  * Finishes an operation started with
b61949
  * gdm_client_get_user_verifier().
b61949
  *
b61949
  * Returns: (transfer full): a #GdmUserVerifier
b61949
  */
b61949
 GdmUserVerifier *
b61949
 gdm_client_get_user_verifier_finish (GdmClient       *client,
b61949
                                      GAsyncResult    *result,
b61949
                                      GError         **error)
b61949
 {
b61949
         GdmUserVerifier *user_verifier;
b61949
 
b61949
         g_return_val_if_fail (GDM_IS_CLIENT (client), FALSE);
b61949
 
b61949
         if (client->priv->user_verifier != NULL)
b61949
                 return g_object_ref (client->priv->user_verifier);
b61949
 
b61949
         user_verifier = g_task_propagate_pointer (G_TASK (result), error);
b61949
         if (user_verifier == NULL)
b61949
                 return NULL;
b61949
 
b61949
         client->priv->user_verifier = user_verifier;
b61949
 
b61949
         g_object_add_weak_pointer (G_OBJECT (client->priv->user_verifier),
b61949
                                    (gpointer *)
b61949
                                    &client->priv->user_verifier);
b61949
 
b61949
-        g_object_weak_ref (G_OBJECT (client->priv->user_verifier),
b61949
-                           (GWeakNotify)
b61949
-                           g_object_unref,
b61949
-                           client->priv->connection);
b61949
-
b61949
         return user_verifier;
b61949
 }
b61949
 
b61949
 /**
b61949
  * gdm_client_get_user_verifier_choice_list:
b61949
  * @client: a #GdmClient
b61949
  *
b61949
  * Gets a #GdmUserVerifierChoiceList object that can be used to
b61949
  * verify a user's local account.
b61949
  *
b61949
  * Returns: (transfer none): #GdmUserVerifierChoiceList or %NULL if user
b61949
  * verifier isn't yet fetched, or daemon doesn't support choice lists
b61949
  */
b61949
 GdmUserVerifierChoiceList *
b61949
 gdm_client_get_user_verifier_choice_list (GdmClient *client)
b61949
 {
b61949
         if (client->priv->user_verifier_extensions == NULL)
b61949
                 return NULL;
b61949
 
b61949
         return g_hash_table_lookup (client->priv->user_verifier_extensions,
b61949
                                     gdm_user_verifier_choice_list_interface_info ()->name);
b61949
 }
b61949
 
b61949
 static void
b61949
 on_timed_login_details_got (GdmGreeter   *greeter,
b61949
                             GAsyncResult *result)
b61949
 {
b61949
     gdm_greeter_call_get_timed_login_details_finish (greeter, NULL, NULL, NULL, result, NULL);
b61949
 }
b61949
 
b61949
@@ -1054,112 +1036,104 @@ gdm_client_get_greeter (GdmClient           *client,
b61949
  * @result: The #GAsyncResult from the callback
b61949
  * @error: a #GError
b61949
  *
b61949
  * Finishes an operation started with
b61949
  * gdm_client_get_greeter().
b61949
  *
b61949
  * Returns: (transfer full): a #GdmGreeter
b61949
  */
b61949
 GdmGreeter *
b61949
 gdm_client_get_greeter_finish (GdmClient       *client,
b61949
                                GAsyncResult    *result,
b61949
                                GError         **error)
b61949
 {
b61949
         GdmGreeter *greeter;
b61949
 
b61949
         g_return_val_if_fail (GDM_IS_CLIENT (client), FALSE);
b61949
 
b61949
         if (client->priv->greeter != NULL)
b61949
                 return g_object_ref (client->priv->greeter);
b61949
 
b61949
         greeter = g_task_propagate_pointer (G_TASK (result), error);
b61949
         if (greeter == NULL)
b61949
                 return NULL;
b61949
 
b61949
         client->priv->greeter = greeter;
b61949
 
b61949
         g_object_add_weak_pointer (G_OBJECT (client->priv->greeter),
b61949
                                    (gpointer *)
b61949
                                    &client->priv->greeter);
b61949
 
b61949
-        g_object_weak_ref (G_OBJECT (client->priv->greeter),
b61949
-                           (GWeakNotify)
b61949
-                           g_object_unref,
b61949
-                           client->priv->connection);
b61949
         return greeter;
b61949
 }
b61949
 
b61949
 /**
b61949
  * gdm_client_get_greeter_sync:
b61949
  * @client: a #GdmClient
b61949
  * @cancellable: a #GCancellable
b61949
  * @error: a #GError
b61949
  *
b61949
  * Gets a #GdmGreeter object that can be used
b61949
  * to do do various login screen related tasks, such
b61949
  * as selecting a users session, and starting that
b61949
  * session.
b61949
  *
b61949
  * Returns: (transfer full): #GdmGreeter or %NULL if caller is not a greeter
b61949
  */
b61949
 GdmGreeter *
b61949
 gdm_client_get_greeter_sync (GdmClient     *client,
b61949
                              GCancellable  *cancellable,
b61949
                              GError       **error)
b61949
 {
b61949
         g_autoptr(GDBusConnection) connection = NULL;
b61949
 
b61949
         if (client->priv->greeter != NULL) {
b61949
                 return g_object_ref (client->priv->greeter);
b61949
         }
b61949
 
b61949
         connection = gdm_client_get_connection_sync (client, cancellable, error);
b61949
 
b61949
         if (connection == NULL) {
b61949
                 return NULL;
b61949
         }
b61949
 
b61949
         client->priv->greeter = gdm_greeter_proxy_new_sync (connection,
b61949
                                                             G_DBUS_PROXY_FLAGS_NONE,
b61949
                                                             NULL,
b61949
                                                             SESSION_DBUS_PATH,
b61949
                                                             cancellable,
b61949
                                                             error);
b61949
 
b61949
         if (client->priv->greeter != NULL) {
b61949
                 g_object_add_weak_pointer (G_OBJECT (client->priv->greeter),
b61949
                                            (gpointer *)
b61949
                                            &client->priv->greeter);
b61949
-                g_object_weak_ref (G_OBJECT (client->priv->greeter),
b61949
-                                   (GWeakNotify)
b61949
-                                   g_object_unref,
b61949
-                                   client->priv->connection);
b61949
 
b61949
                 query_for_timed_login_requested_signal (client->priv->greeter);
b61949
         }
b61949
 
b61949
         return client->priv->greeter;
b61949
 }
b61949
 
b61949
 static void
b61949
 on_remote_greeter_proxy_created (GObject            *object,
b61949
                                  GAsyncResult       *result,
b61949
                                  GTask              *task)
b61949
 {
b61949
         GdmRemoteGreeter *remote_greeter;
b61949
         GError           *error = NULL;
b61949
 
b61949
         remote_greeter = gdm_remote_greeter_proxy_new_finish (result, &error);
b61949
         if (remote_greeter == NULL) {
b61949
                 g_task_return_error (task, error);
b61949
                 g_object_unref (task);
b61949
                 return;
b61949
         }
b61949
 
b61949
         g_task_return_pointer (task,
b61949
                                remote_greeter,
b61949
                                (GDestroyNotify) g_object_unref);
b61949
         g_object_unref (task);
b61949
 }
b61949
 
b61949
 static void
b61949
 on_connection_for_remote_greeter (GdmClient          *client,
b61949
@@ -1236,113 +1210,103 @@ gdm_client_get_remote_greeter (GdmClient           *client,
b61949
  * @result: The #GAsyncResult from the callback
b61949
  * @error: a #GError
b61949
  *
b61949
  * Finishes an operation started with
b61949
  * gdm_client_get_remote_greeter().
b61949
  *
b61949
  * Returns: (transfer full): a #GdmRemoteGreeter
b61949
  */
b61949
 GdmRemoteGreeter *
b61949
 gdm_client_get_remote_greeter_finish (GdmClient     *client,
b61949
                                       GAsyncResult  *result,
b61949
                                       GError       **error)
b61949
 {
b61949
         GdmRemoteGreeter *remote_greeter;
b61949
 
b61949
         g_return_val_if_fail (GDM_IS_CLIENT (client), FALSE);
b61949
 
b61949
         if (client->priv->remote_greeter != NULL)
b61949
                 return g_object_ref (client->priv->remote_greeter);
b61949
 
b61949
         remote_greeter = g_task_propagate_pointer (G_TASK (result), error);
b61949
         if (remote_greeter == NULL)
b61949
                 return NULL;
b61949
 
b61949
         client->priv->remote_greeter = remote_greeter;
b61949
 
b61949
         g_object_add_weak_pointer (G_OBJECT (client->priv->remote_greeter),
b61949
                                    (gpointer *)
b61949
                                    &client->priv->remote_greeter);
b61949
 
b61949
-        g_object_weak_ref (G_OBJECT (client->priv->remote_greeter),
b61949
-                           (GWeakNotify)
b61949
-                           g_object_unref,
b61949
-                           client->priv->connection);
b61949
-
b61949
         return remote_greeter;
b61949
 }
b61949
 
b61949
 /**
b61949
  * gdm_client_get_remote_greeter_sync:
b61949
  * @client: a #GdmClient
b61949
  * @cancellable: a #GCancellable
b61949
  * @error: a #GError
b61949
  *
b61949
  * Gets a #GdmRemoteGreeter object that can be used
b61949
  * to do do various remote login screen related tasks,
b61949
  * such as disconnecting.
b61949
  *
b61949
  * Returns: (transfer full): #GdmRemoteGreeter or %NULL if caller is not remote
b61949
  */
b61949
 GdmRemoteGreeter *
b61949
 gdm_client_get_remote_greeter_sync (GdmClient     *client,
b61949
                                     GCancellable  *cancellable,
b61949
                                     GError       **error)
b61949
 {
b61949
         g_autoptr(GDBusConnection) connection = NULL;
b61949
 
b61949
         if (client->priv->remote_greeter != NULL) {
b61949
                 return g_object_ref (client->priv->remote_greeter);
b61949
         }
b61949
 
b61949
         connection = gdm_client_get_connection_sync (client, cancellable, error);
b61949
 
b61949
         if (connection == NULL) {
b61949
                 return NULL;
b61949
         }
b61949
 
b61949
         client->priv->remote_greeter = gdm_remote_greeter_proxy_new_sync (connection,
b61949
                                                                           G_DBUS_PROXY_FLAGS_NONE,
b61949
                                                                           NULL,
b61949
                                                                           SESSION_DBUS_PATH,
b61949
                                                                           cancellable,
b61949
                                                                           error);
b61949
 
b61949
         if (client->priv->remote_greeter != NULL) {
b61949
                 g_object_add_weak_pointer (G_OBJECT (client->priv->remote_greeter),
b61949
                                            (gpointer *)
b61949
                                            &client->priv->remote_greeter);
b61949
-                g_object_ref (connection);
b61949
-                g_object_weak_ref (G_OBJECT (client->priv->remote_greeter),
b61949
-                                   (GWeakNotify)
b61949
-                                   g_object_unref,
b61949
-                                   client->priv->connection);
b61949
         }
b61949
 
b61949
         return client->priv->remote_greeter;
b61949
 }
b61949
 
b61949
 static void
b61949
 on_chooser_proxy_created (GObject            *source,
b61949
                           GAsyncResult       *result,
b61949
                           GTask              *task)
b61949
 {
b61949
         GdmChooser   *chooser;
b61949
         GError       *error = NULL;
b61949
 
b61949
         chooser = gdm_chooser_proxy_new_finish (result, &error);
b61949
         if (chooser == NULL) {
b61949
                 g_task_return_error (task, error);
b61949
                 g_object_unref (task);
b61949
                 return;
b61949
         }
b61949
 
b61949
         g_task_return_pointer (task,
b61949
                                chooser,
b61949
                                (GDestroyNotify) g_object_unref);
b61949
         g_object_unref (task);
b61949
 }
b61949
 
b61949
 static void
b61949
 on_connection_for_chooser (GdmClient          *client,
b61949
                            GAsyncResult       *result,
b61949
                            GTask              *task)
b61949
@@ -1417,114 +1381,103 @@ gdm_client_get_chooser (GdmClient           *client,
b61949
  * @result: The #GAsyncResult from the callback
b61949
  * @error: a #GError
b61949
  *
b61949
  * Finishes an operation started with
b61949
  * gdm_client_get_chooser().
b61949
  *
b61949
  * Returns: (transfer full): a #GdmChooser
b61949
  */
b61949
 GdmChooser *
b61949
 gdm_client_get_chooser_finish (GdmClient       *client,
b61949
                                GAsyncResult    *result,
b61949
                                GError         **error)
b61949
 {
b61949
         GdmChooser *chooser;
b61949
 
b61949
         g_return_val_if_fail (GDM_IS_CLIENT (client), FALSE);
b61949
 
b61949
         if (client->priv->chooser != NULL)
b61949
                 return g_object_ref (client->priv->chooser);
b61949
 
b61949
         chooser = g_task_propagate_pointer (G_TASK (result), error);
b61949
         if (chooser == NULL)
b61949
                 return NULL;
b61949
 
b61949
         client->priv->chooser = chooser;
b61949
 
b61949
         g_object_add_weak_pointer (G_OBJECT (client->priv->chooser),
b61949
                                    (gpointer *)
b61949
                                    &client->priv->chooser);
b61949
 
b61949
-        g_object_ref (connection);
b61949
-        g_object_weak_ref (G_OBJECT (client->priv->chooser),
b61949
-                           (GWeakNotify)
b61949
-                           g_object_unref,
b61949
-                           client->priv->connection);
b61949
-
b61949
         return chooser;
b61949
 }
b61949
 
b61949
 /**
b61949
  * gdm_client_get_chooser_sync:
b61949
  * @client: a #GdmClient
b61949
  * @cancellable: a #GCancellable
b61949
  * @error: a #GError
b61949
  *
b61949
  * Gets a #GdmChooser object that can be used
b61949
  * to do do various XDMCP chooser related tasks, such
b61949
  * as selecting a host or disconnecting.
b61949
  *
b61949
  * Returns: (transfer full): #GdmChooser or %NULL if caller is not a chooser
b61949
  */
b61949
 GdmChooser *
b61949
 gdm_client_get_chooser_sync (GdmClient     *client,
b61949
                              GCancellable  *cancellable,
b61949
                              GError       **error)
b61949
 {
b61949
         g_autoptr(GDBusConnection) connection = NULL;
b61949
 
b61949
         if (client->priv->chooser != NULL) {
b61949
                 return g_object_ref (client->priv->chooser);
b61949
         }
b61949
 
b61949
         connection = gdm_client_get_connection_sync (client, cancellable, error);
b61949
 
b61949
         if (connection == NULL) {
b61949
                 return NULL;
b61949
         }
b61949
 
b61949
         client->priv->chooser = gdm_chooser_proxy_new_sync (connection,
b61949
                                                             G_DBUS_PROXY_FLAGS_NONE,
b61949
                                                             NULL,
b61949
                                                             SESSION_DBUS_PATH,
b61949
                                                             cancellable,
b61949
                                                             error);
b61949
 
b61949
         if (client->priv->chooser != NULL) {
b61949
                 g_object_add_weak_pointer (G_OBJECT (client->priv->chooser),
b61949
                                            (gpointer *)
b61949
                                            &client->priv->chooser);
b61949
-                g_object_ref (connection);
b61949
-                g_object_weak_ref (G_OBJECT (client->priv->chooser),
b61949
-                                   (GWeakNotify)
b61949
-                                   g_object_unref,
b61949
-                                   client->priv->connection);
b61949
         }
b61949
 
b61949
         return client->priv->chooser;
b61949
 }
b61949
 
b61949
 static void
b61949
 gdm_client_class_init (GdmClientClass *klass)
b61949
 {
b61949
         GObjectClass   *object_class = G_OBJECT_CLASS (klass);
b61949
 
b61949
         object_class->finalize = gdm_client_finalize;
b61949
 
b61949
         g_type_class_add_private (klass, sizeof (GdmClientPrivate));
b61949
 
b61949
 }
b61949
 
b61949
 static void
b61949
 gdm_client_init (GdmClient *client)
b61949
 {
b61949
 
b61949
         client->priv = GDM_CLIENT_GET_PRIVATE (client);
b61949
 }
b61949
 
b61949
 static void
b61949
 gdm_client_finalize (GObject *object)
b61949
 {
b61949
         GdmClient *client;
b61949
 
b61949
         g_return_if_fail (object != NULL);
b61949
         g_return_if_fail (GDM_IS_CLIENT (object));
b61949
-- 
b61949
2.26.2
b61949