diff options
author | Dan Williams <dcbw@redhat.com> | 2014-10-10 10:27:52 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-10-10 10:27:52 -0500 |
commit | 022f25a96b5cb2972ec6f9315339ad945d460df8 (patch) | |
tree | 18c756c3d144d38ffe2d7cbdd3791ca2ab74dee2 | |
parent | d059d08c4f28ebf6961dab172da6d59cad9f49e2 (diff) | |
download | network-manager-applet-022f25a96b5cb2972ec6f9315339ad945d460df8.tar.gz |
editor: clean up object dispose()
Remove unused 'disposed' private variables and make every dispose()
safe to be called multiple times.
-rw-r--r-- | src/connection-editor/ce-page.c | 20 | ||||
-rw-r--r-- | src/connection-editor/ce-page.h | 2 | ||||
-rw-r--r-- | src/connection-editor/ce-polkit-button.c | 18 | ||||
-rw-r--r-- | src/connection-editor/page-8021x-security.c | 11 | ||||
-rw-r--r-- | src/connection-editor/page-dsl.c | 2 | ||||
-rw-r--r-- | src/connection-editor/page-ethernet.c | 2 | ||||
-rw-r--r-- | src/connection-editor/page-general.c | 12 | ||||
-rw-r--r-- | src/connection-editor/page-ip4.c | 5 | ||||
-rw-r--r-- | src/connection-editor/page-ip6.c | 5 | ||||
-rw-r--r-- | src/connection-editor/page-mobile.c | 8 | ||||
-rw-r--r-- | src/connection-editor/page-ppp.c | 11 | ||||
-rw-r--r-- | src/connection-editor/page-vpn.c | 13 | ||||
-rw-r--r-- | src/connection-editor/page-wifi-security.c | 9 | ||||
-rw-r--r-- | src/connection-editor/page-wifi-security.h | 1 | ||||
-rw-r--r-- | src/connection-editor/page-wifi.c | 1 | ||||
-rw-r--r-- | src/connection-editor/page-wimax.c | 2 |
16 files changed, 28 insertions, 94 deletions
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c index c63a7523..001af304 100644 --- a/src/connection-editor/ce-page.c +++ b/src/connection-editor/ce-page.c @@ -374,22 +374,10 @@ dispose (GObject *object) { CEPage *self = CE_PAGE (object); - if (self->disposed) - return; - - self->disposed = TRUE; - - if (self->page) - g_object_unref (self->page); - - if (self->builder) - g_object_unref (self->builder); - - if (self->proxy) - g_object_unref (self->proxy); - - if (self->connection) - g_object_unref (self->connection); + g_clear_object (&self->page); + g_clear_object (&self->builder); + g_clear_object (&self->proxy); + g_clear_object (&self->connection); G_OBJECT_CLASS (ce_page_parent_class)->dispose (object); } diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h index 9d533203..639beb3e 100644 --- a/src/connection-editor/ce-page.h +++ b/src/connection-editor/ce-page.h @@ -76,8 +76,6 @@ typedef struct { GtkWindow *parent_window; NMClient *client; NMRemoteSettings *settings; - - gboolean disposed; } CEPage; typedef struct { diff --git a/src/connection-editor/ce-polkit-button.c b/src/connection-editor/ce-polkit-button.c index e2701f3e..892311a6 100644 --- a/src/connection-editor/ce-polkit-button.c +++ b/src/connection-editor/ce-polkit-button.c @@ -32,8 +32,6 @@ G_DEFINE_TYPE (CEPolkitButton, ce_polkit_button, GTK_TYPE_BUTTON) #define CE_POLKIT_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CE_TYPE_POLKIT_BUTTON, CEPolkitButtonPrivate)) typedef struct { - gboolean disposed; - char *tooltip; char *auth_tooltip; gboolean master_sensitive; @@ -190,17 +188,15 @@ dispose (GObject *object) { CEPolkitButtonPrivate *priv = CE_POLKIT_BUTTON_GET_PRIVATE (object); - if (priv->disposed == FALSE) { - priv->disposed = TRUE; - - if (priv->perm_id) - g_signal_handler_disconnect (priv->client, priv->perm_id); - - g_object_unref (priv->client); - g_object_unref (priv->auth); - g_object_unref (priv->stock); + if (priv->perm_id) { + g_signal_handler_disconnect (priv->client, priv->perm_id); + priv->perm_id = 0; } + g_clear_object (&priv->client); + g_clear_object (&priv->auth); + g_clear_object (&priv->stock); + G_OBJECT_CLASS (ce_polkit_button_parent_class)->dispose (object); } diff --git a/src/connection-editor/page-8021x-security.c b/src/connection-editor/page-8021x-security.c index 62a8e84c..5aca1e3a 100644 --- a/src/connection-editor/page-8021x-security.c +++ b/src/connection-editor/page-8021x-security.c @@ -49,8 +49,6 @@ typedef struct { WirelessSecurity *security; gboolean initial_have_8021x; - - gboolean disposed; } CEPage8021xSecurityPrivate; static void @@ -195,13 +193,10 @@ dispose (GObject *object) { CEPage8021xSecurityPrivate *priv = CE_PAGE_8021X_SECURITY_GET_PRIVATE (object); - if (priv->disposed) - return; - - priv->disposed = TRUE; - - if (priv->security) + if (priv->security) { wireless_security_unref (priv->security); + priv->security = NULL; + } G_OBJECT_CLASS (ce_page_8021x_security_parent_class)->dispose (object); } diff --git a/src/connection-editor/page-dsl.c b/src/connection-editor/page-dsl.c index ea35b276..c327979f 100644 --- a/src/connection-editor/page-dsl.c +++ b/src/connection-editor/page-dsl.c @@ -45,8 +45,6 @@ typedef struct { GtkEntry *username; GtkEntry *password; GtkEntry *service; - - gboolean disposed; } CEPageDslPrivate; static void diff --git a/src/connection-editor/page-ethernet.c b/src/connection-editor/page-ethernet.c index d24a10f3..16c82043 100644 --- a/src/connection-editor/page-ethernet.c +++ b/src/connection-editor/page-ethernet.c @@ -49,8 +49,6 @@ typedef struct { GtkToggleButton *duplex; GtkToggleButton *autonegotiate; GtkSpinButton *mtu; - - gboolean disposed; } CEPageEthernetPrivate; #define PORT_DEFAULT 0 diff --git a/src/connection-editor/page-general.c b/src/connection-editor/page-general.c index 462e5464..5cece094 100644 --- a/src/connection-editor/page-general.c +++ b/src/connection-editor/page-general.c @@ -151,16 +151,10 @@ general_private_init (CEPageGeneral *self) static void dispose (GObject *object) { - CEPageGeneral *self = CE_PAGE_GENERAL (object); - CEPageGeneralPrivate *priv = CE_PAGE_GENERAL_GET_PRIVATE (self); - - if (priv->remote_settings) { - g_object_unref (priv->remote_settings); - priv->remote_settings = NULL; - } + CEPageGeneralPrivate *priv = CE_PAGE_GENERAL_GET_PRIVATE (object); - g_strfreev (priv->zones); - priv->zones = NULL; + g_clear_object (&priv->remote_settings); + g_clear_pointer (&priv->zones, g_strfreev); G_OBJECT_CLASS (ce_page_general_parent_class)->dispose (object); } diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c index fe1a5759..f47725a9 100644 --- a/src/connection-editor/page-ip4.c +++ b/src/connection-editor/page-ip4.c @@ -1245,14 +1245,13 @@ dispose (GObject *object) CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self); int i; - if (priv->window_group) - g_object_unref (priv->window_group); + g_clear_object (&priv->window_group); /* Mark CEPageIP4 object as invalid; store this indication to cells to be usable in callbacks */ for (i = 0; i <= COL_LAST; i++) g_object_set_data (G_OBJECT (priv->addr_cells[i]), "ce-page-not-valid", GUINT_TO_POINTER (1)); - g_free (priv->connection_id); + g_clear_pointer (&priv->connection_id, g_free); G_OBJECT_CLASS (ce_page_ip4_parent_class)->dispose (object); } diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c index 57964417..5340d78f 100644 --- a/src/connection-editor/page-ip6.c +++ b/src/connection-editor/page-ip6.c @@ -1232,14 +1232,13 @@ dispose (GObject *object) CEPageIP6Private *priv = CE_PAGE_IP6_GET_PRIVATE (self); int i; - if (priv->window_group) - g_object_unref (priv->window_group); + g_clear_object (&priv->window_group); /* Mark CEPageIP6 object as invalid; store this indication to cells to be usable in callbacks */ for (i = 0; i <= COL_LAST; i++) g_object_set_data (G_OBJECT (priv->addr_cells[i]), "ce-page-not-valid", GUINT_TO_POINTER (1)); - g_free (priv->connection_id); + g_clear_pointer (&priv->connection_id, g_free); G_OBJECT_CLASS (ce_page_ip6_parent_class)->dispose (object); } diff --git a/src/connection-editor/page-mobile.c b/src/connection-editor/page-mobile.c index 57424260..b442a673 100644 --- a/src/connection-editor/page-mobile.c +++ b/src/connection-editor/page-mobile.c @@ -59,8 +59,6 @@ typedef struct { GtkWindowGroup *window_group; gboolean window_added; - - gboolean disposed; } CEPageMobilePrivate; #define NET_TYPE_ANY 0 @@ -473,11 +471,7 @@ validate (CEPage *page, NMConnection *connection, GError **error) static void dispose (GObject *object) { - CEPageMobile *self = CE_PAGE_MOBILE (object); - CEPageMobilePrivate *priv = CE_PAGE_MOBILE_GET_PRIVATE (self); - - if (priv->window_group) - g_object_unref (priv->window_group); + g_clear_object (&CE_PAGE_MOBILE_GET_PRIVATE (object)->window_group); G_OBJECT_CLASS (ce_page_mobile_parent_class)->dispose (object); } diff --git a/src/connection-editor/page-ppp.c b/src/connection-editor/page-ppp.c index 2f9f8d60..7e7c1aa4 100644 --- a/src/connection-editor/page-ppp.c +++ b/src/connection-editor/page-ppp.c @@ -75,8 +75,6 @@ typedef struct { GtkWindowGroup *window_group; gboolean window_added; char *connection_id; - - gboolean disposed; } CEPagePppPrivate; static void @@ -378,13 +376,10 @@ ce_page_ppp_init (CEPagePpp *self) static void dispose (GObject *object) { - CEPagePpp *self = CE_PAGE_PPP (object); - CEPagePppPrivate *priv = CE_PAGE_PPP_GET_PRIVATE (self); - - if (priv->window_group) - g_object_unref (priv->window_group); + CEPagePppPrivate *priv = CE_PAGE_PPP_GET_PRIVATE (object); - g_free (priv->connection_id); + g_clear_object (&priv->window_group); + g_clear_pointer (&priv->connection_id, g_free); G_OBJECT_CLASS (ce_page_ppp_parent_class)->dispose (object); } diff --git a/src/connection-editor/page-vpn.c b/src/connection-editor/page-vpn.c index 81592c8d..957f35d2 100644 --- a/src/connection-editor/page-vpn.c +++ b/src/connection-editor/page-vpn.c @@ -50,8 +50,6 @@ typedef struct { NMVpnPluginUiInterface *plugin; NMVpnPluginUiWidgetInterface *ui; - - gboolean disposed; } CEPageVpnPrivate; static void @@ -166,15 +164,8 @@ dispose (GObject *object) { CEPageVpnPrivate *priv = CE_PAGE_VPN_GET_PRIVATE (object); - if (priv->disposed) - return; - - priv->disposed = TRUE; - - if (priv->ui) - g_object_unref (priv->ui); - - g_free (priv->service_type); + g_clear_object (&priv->ui); + g_clear_pointer (&priv->service_type, g_free); G_OBJECT_CLASS (ce_page_vpn_parent_class)->dispose (object); } diff --git a/src/connection-editor/page-wifi-security.c b/src/connection-editor/page-wifi-security.c index 488898c0..ef65fe6d 100644 --- a/src/connection-editor/page-wifi-security.c +++ b/src/connection-editor/page-wifi-security.c @@ -435,7 +435,6 @@ ce_page_wifi_security_new (NMConnection *connection, static void ce_page_wifi_security_init (CEPageWifiSecurity *self) { - self->disposed = FALSE; } static void @@ -443,13 +442,7 @@ dispose (GObject *object) { CEPageWifiSecurity *self = CE_PAGE_WIFI_SECURITY (object); - if (self->disposed) - return; - - self->disposed = TRUE; - - if (self->group) - g_object_unref (self->group); + g_clear_object (&self->group); G_OBJECT_CLASS (ce_page_wifi_security_parent_class)->dispose (object); } diff --git a/src/connection-editor/page-wifi-security.h b/src/connection-editor/page-wifi-security.h index a0dd0ed1..b8072ab2 100644 --- a/src/connection-editor/page-wifi-security.h +++ b/src/connection-editor/page-wifi-security.h @@ -43,7 +43,6 @@ typedef struct { CEPage parent; - gboolean disposed; GtkSizeGroup *group; GtkComboBox *security_combo; gboolean adhoc; diff --git a/src/connection-editor/page-wifi.c b/src/connection-editor/page-wifi.c index d0a56173..dbf4e203 100644 --- a/src/connection-editor/page-wifi.c +++ b/src/connection-editor/page-wifi.c @@ -56,7 +56,6 @@ typedef struct { GtkSizeGroup *group; int last_channel; - gboolean disposed; } CEPageWifiPrivate; static void diff --git a/src/connection-editor/page-wimax.c b/src/connection-editor/page-wimax.c index ef5cd619..3b786c2e 100644 --- a/src/connection-editor/page-wimax.c +++ b/src/connection-editor/page-wimax.c @@ -39,8 +39,6 @@ typedef struct { GtkEntry *name; GtkComboBoxText *device_mac; /* Permanent MAC of the device */ - - gboolean disposed; } CEPageWimaxPrivate; static void |