Commit 022f25a9 authored by Dan Williams's avatar Dan Williams

editor: clean up object dispose()

Remove unused 'disposed' private variables and make every dispose()
safe to be called multiple times.
parent d059d08c
......@@ -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);
}
......
......@@ -76,8 +76,6 @@ typedef struct {
GtkWindow *parent_window;
NMClient *client;
NMRemoteSettings *settings;
gboolean disposed;
} CEPage;
typedef struct {
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -45,8 +45,6 @@ typedef struct {
GtkEntry *username;
GtkEntry *password;
GtkEntry *service;
gboolean disposed;
} CEPageDslPrivate;
static void
......
......@@ -49,8 +49,6 @@ typedef struct {
GtkToggleButton *duplex;
GtkToggleButton *autonegotiate;
GtkSpinButton *mtu;
gboolean disposed;
} CEPageEthernetPrivate;
#define PORT_DEFAULT 0
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -43,7 +43,6 @@
typedef struct {
CEPage parent;
gboolean disposed;
GtkSizeGroup *group;
GtkComboBox *security_combo;
gboolean adhoc;
......
......@@ -56,7 +56,6 @@ typedef struct {
GtkSizeGroup *group;
int last_channel;
gboolean disposed;
} CEPageWifiPrivate;
static void
......
......@@ -39,8 +39,6 @@ typedef struct {
GtkEntry *name;
GtkComboBoxText *device_mac; /* Permanent MAC of the device */
gboolean disposed;
} CEPageWimaxPrivate;
static void
......
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