diff options
author | Richard Hughes <richard@hughsie.com> | 2012-07-23 10:14:31 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2012-07-23 10:14:31 +0100 |
commit | 08532a3a86e2a8ee6621c857281cf9a06bc77545 (patch) | |
tree | dea0a7d0c9aea3af36d75638b4e4f88fa92d3554 /panels/network/net-device.c | |
parent | b06bb9e5f36a26f99506c2ef0d284885b3ba6e08 (diff) | |
download | gnome-control-center-08532a3a86e2a8ee6621c857281cf9a06bc77545.tar.gz |
network: Prevent a crash when a device is removed and then re-added
Diffstat (limited to 'panels/network/net-device.c')
-rw-r--r-- | panels/network/net-device.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/panels/network/net-device.c b/panels/network/net-device.c index 5f014109e..c53c90969 100644 --- a/panels/network/net-device.c +++ b/panels/network/net-device.c @@ -40,6 +40,7 @@ struct _NetDevicePrivate { NMDevice *nm_device; + guint changed_id; }; enum { @@ -281,11 +282,15 @@ net_device_set_property (GObject *device_, switch (prop_id) { case PROP_DEVICE: + if (priv->changed_id != 0) { + g_signal_handler_disconnect (priv->nm_device, + priv->changed_id); + } priv->nm_device = g_value_dup_object (value); - g_signal_connect (priv->nm_device, - "state-changed", - G_CALLBACK (state_changed_cb), - net_device); + priv->changed_id = g_signal_connect (priv->nm_device, + "state-changed", + G_CALLBACK (state_changed_cb), + net_device); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (net_device, prop_id, pspec); @@ -299,6 +304,10 @@ net_device_finalize (GObject *object) NetDevice *device = NET_DEVICE (object); NetDevicePrivate *priv = device->priv; + if (priv->changed_id != 0) { + g_signal_handler_disconnect (priv->nm_device, + priv->changed_id); + } if (priv->nm_device != NULL) g_object_unref (priv->nm_device); |