device/macvlan: implement dispose()
authorBeniamino Galvani <bgalvani@redhat.com>
Tue, 19 Jan 2016 12:52:21 +0000 (13:52 +0100)
committerBeniamino Galvani <bgalvani@redhat.com>
Wed, 20 Jan 2016 10:41:59 +0000 (11:41 +0100)
When the object gets disposed, parent must be unreferenced and signals
disconnected.

Fixes: 4de8851eca06d797f1a3c89f5710d51018ca2bff

https://bugzilla.redhat.com/show_bug.cgi?id=1299803

src/devices/nm-device-macvlan.c

index 8123a79..6f3ac4b 100644 (file)
@@ -139,8 +139,7 @@ nm_device_macvlan_set_parent (NMDeviceMacvlan *self, NMDevice *parent)
        if (parent == priv->parent)
                return;
 
-       if (priv->parent_state_id)
-               nm_clear_g_signal_handler (priv->parent, &priv->parent_state_id);
+       nm_clear_g_signal_handler (priv->parent, &priv->parent_state_id);
 
        g_clear_object (&priv->parent);
 
@@ -620,6 +619,14 @@ set_property (GObject *object, guint prop_id,
        }
 }
 
+static void
+dispose (GObject *object)
+{
+       nm_device_macvlan_set_parent (NM_DEVICE_MACVLAN (object), NULL);
+
+       G_OBJECT_CLASS (nm_device_macvlan_parent_class)->dispose (object);
+}
+
 static void
 nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
 {
@@ -630,6 +637,7 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
 
        NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_MACVLAN, NM_LINK_TYPE_MACVTAP)
 
+       object_class->dispose = dispose;
        object_class->get_property = get_property;
        object_class->set_property = set_property;