diff options
author | Dan Winship <danw@gnome.org> | 2014-08-26 08:31:04 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-09-04 09:21:04 -0400 |
commit | 074c2093b6a733c3d5712a7c58386e1e652a8903 (patch) | |
tree | 37c48864a54e5596ad7775f7368cad98dba6ce55 /libnm/nm-device-bond.c | |
parent | 20dc44bda9e07222e46675507731b1532b4b20f2 (diff) | |
download | NetworkManager-074c2093b6a733c3d5712a7c58386e1e652a8903.tar.gz |
libnm: drop NM_TYPE_OBJECT_ARRAY, use G_TYPE_PTR_ARRAY
Use G_TYPE_PTR_ARRAY for GPtrArray-of-NMObject-valued properties,
because it has better introspection/bindings support.
As with the strdict change in libnm-core, we need to manually copy the
array in get_property() implementations, to preserve the standard
semantics that get_property() returns a copy, not the internal array.
(This patch also changes those properties so that they are always
non-NULL until dispose(); previously some of them could be either NULL
or 0-length at different times.)
Diffstat (limited to 'libnm/nm-device-bond.c')
-rw-r--r-- | libnm/nm-device-bond.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/libnm/nm-device-bond.c b/libnm/nm-device-bond.c index 03eb4161ea..d0a3e94a82 100644 --- a/libnm/nm-device-bond.c +++ b/libnm/nm-device-bond.c @@ -30,7 +30,7 @@ #include "nm-device-bond.h" #include "nm-device-private.h" #include "nm-object-private.h" -#include "nm-types.h" +#include "nm-core-internal.h" G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE) @@ -204,11 +204,7 @@ dispose (GObject *object) g_clear_object (&priv->proxy); - if (priv->slaves) { - g_ptr_array_set_free_func (priv->slaves, g_object_unref); - g_ptr_array_free (priv->slaves, TRUE); - priv->slaves = NULL; - } + g_clear_pointer (&priv->slaves, g_ptr_array_unref); G_OBJECT_CLASS (nm_device_bond_parent_class)->dispose (object); } @@ -239,7 +235,7 @@ get_property (GObject *object, g_value_set_boolean (value, nm_device_bond_get_carrier (device)); break; case PROP_SLAVES: - g_value_set_boxed (value, nm_device_bond_get_slaves (device)); + g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_bond_get_slaves (device))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -296,12 +292,14 @@ nm_device_bond_class_init (NMDeviceBondClass *bond_class) /** * NMDeviceBond:slaves: * - * The devices (#NMDevice) slaved to the bond device. + * The devices slaved to the bond device. + * + * Element-type: NMDevice **/ g_object_class_install_property (object_class, PROP_SLAVES, g_param_spec_boxed (NM_DEVICE_BOND_SLAVES, "", "", - NM_TYPE_OBJECT_ARRAY, + G_TYPE_PTR_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); } |