[network-manager-applet] applet-device-wifi: refactor NMAWifiDialog:dispose()



commit 242d22539ae9b93c3c265a9bb43e6a5749b71ad4
Author: Thomas Haller <thaller redhat com>
Date:   Wed Jun 3 12:25:20 2015 +0200

    applet-device-wifi: refactor NMAWifiDialog:dispose()

 src/applet-device-wifi.c     |    4 +++-
 src/libnma/nma-wifi-dialog.c |   36 ++++++++++++++----------------------
 2 files changed, 17 insertions(+), 23 deletions(-)
---
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 9b31872..0a4e62e 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -1462,6 +1462,7 @@ free_wifi_info (SecretsRequest *req)
        if (info->dialog) {
                gtk_widget_hide (info->dialog);
                gtk_widget_destroy (info->dialog);
+               info->dialog = NULL;
        }
 }
 
@@ -1564,10 +1565,11 @@ wifi_get_secrets (SecretsRequest *req, GError **error)
 {
        NMWifiInfo *info = (NMWifiInfo *) req;
 
-       applet_secrets_request_set_free_func (req, free_wifi_info);
+       g_return_val_if_fail (!info->dialog, FALSE);
 
        info->dialog = nma_wifi_dialog_new (req->applet->nm_client, req->connection, NULL, NULL, TRUE);
        if (info->dialog) {
+               applet_secrets_request_set_free_func (req, free_wifi_info);
                g_signal_connect (info->dialog, "response",
                                  G_CALLBACK (get_secrets_dialog_response_cb),
                                  info);
diff --git a/src/libnma/nma-wifi-dialog.c b/src/libnma/nma-wifi-dialog.c
index 4f86a39..5c2ba7f 100644
--- a/src/libnma/nma-wifi-dialog.c
+++ b/src/libnma/nma-wifi-dialog.c
@@ -68,8 +68,6 @@ typedef struct {
        guint revalidate_id;
 
        GetSecretsInfo *secrets_info;
-
-       gboolean disposed;
 } NMAWifiDialogPrivate;
 
 enum {
@@ -1361,36 +1359,30 @@ dispose (GObject *object)
 {
        NMAWifiDialogPrivate *priv = NMA_WIFI_DIALOG_GET_PRIVATE (object);
 
-       if (priv->disposed) {
-               G_OBJECT_CLASS (nma_wifi_dialog_parent_class)->dispose (object);
-               return;
-       }
 
-       priv->disposed = TRUE;
-
-       if (priv->secrets_info)
+       if (priv->secrets_info) {
                priv->secrets_info->canceled = TRUE;
+               priv->secrets_info = NULL;
+       }
 
-       g_object_unref (priv->client);
-       g_object_unref (priv->builder);
+       g_clear_object (&priv->client);
+       g_clear_object (&priv->builder);
 
-       g_object_unref (priv->device_model);
-       g_object_unref (priv->connection_model);
+       g_clear_object (&priv->device_model);
+       g_clear_object (&priv->connection_model);
 
-       if (priv->group)
-               g_object_unref (priv->group);
+       g_clear_object (&priv->group);
 
-       if (priv->connection)
-               g_object_unref (priv->connection);
+       g_clear_object (&priv->connection);
 
-       if (priv->device)
-               g_object_unref (priv->device);
+       g_clear_object (&priv->device);
 
-       if (priv->ap)
-               g_object_unref (priv->ap);
+       g_clear_object (&priv->ap);
 
-       if (priv->revalidate_id)
+       if (priv->revalidate_id) {
                g_source_remove (priv->revalidate_id);
+               priv->revalidate_id = 0;
+       }
 
        G_OBJECT_CLASS (nma_wifi_dialog_parent_class)->dispose (object);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]