mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 09:40:17 +01:00
libnm-glib: make _nm_object_cache_get() return a referenced object
This commit is contained in:
parent
a9a30eb08c
commit
ccfc034a0d
7 changed files with 14 additions and 25 deletions
|
|
@ -1024,7 +1024,7 @@ client_device_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
|
|||
|
||||
device = G_OBJECT (_nm_object_cache_get (path));
|
||||
if (device) {
|
||||
g_ptr_array_add (priv->devices, g_object_ref (device));
|
||||
g_ptr_array_add (priv->devices, device);
|
||||
} else {
|
||||
device = G_OBJECT (nm_device_new (connection, path));
|
||||
if (device)
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ access_point_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
|
|||
priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
ap = G_OBJECT (_nm_object_cache_get (path));
|
||||
if (ap) {
|
||||
g_ptr_array_add (priv->aps, g_object_ref (ap));
|
||||
g_ptr_array_add (priv->aps, ap);
|
||||
} else {
|
||||
ap = G_OBJECT (nm_access_point_new (connection, path));
|
||||
if (ap)
|
||||
|
|
@ -567,9 +567,7 @@ demarshal_active_ap (NMObject *object, GParamSpec *pspec, GValue *value, gpointe
|
|||
priv->null_active_ap = TRUE;
|
||||
else {
|
||||
ap = NM_ACCESS_POINT (_nm_object_cache_get (path));
|
||||
if (ap)
|
||||
ap = g_object_ref (ap);
|
||||
else {
|
||||
if (!ap) {
|
||||
connection = nm_object_get_connection (object);
|
||||
ap = NM_ACCESS_POINT (nm_access_point_new (connection, path));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ nsp_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
|
|||
priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
|
||||
nsp = G_OBJECT (_nm_object_cache_get (path));
|
||||
if (nsp) {
|
||||
g_ptr_array_add (priv->nsps, g_object_ref (nsp));
|
||||
g_ptr_array_add (priv->nsps, nsp);
|
||||
} else {
|
||||
nsp = G_OBJECT (nm_wimax_nsp_new (connection, path));
|
||||
if (nsp)
|
||||
|
|
@ -601,9 +601,7 @@ demarshal_active_nsp (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
|
|||
priv->null_active_nsp = TRUE;
|
||||
else {
|
||||
nsp = NM_WIMAX_NSP (_nm_object_cache_get (path));
|
||||
if (nsp)
|
||||
nsp = g_object_ref (nsp);
|
||||
else {
|
||||
if (!nsp) {
|
||||
connection = nm_object_get_connection (object);
|
||||
nsp = NM_WIMAX_NSP (nm_wimax_nsp_new (connection, path));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,9 +127,7 @@ demarshal_ip4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
|
|||
priv->null_ip4_config = TRUE;
|
||||
else {
|
||||
config = NM_IP4_CONFIG (_nm_object_cache_get (path));
|
||||
if (config)
|
||||
config = g_object_ref (config);
|
||||
else {
|
||||
if (!config) {
|
||||
connection = nm_object_get_connection (object);
|
||||
config = NM_IP4_CONFIG (nm_ip4_config_new (connection, path));
|
||||
}
|
||||
|
|
@ -167,9 +165,7 @@ demarshal_dhcp4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoi
|
|||
priv->null_dhcp4_config = TRUE;
|
||||
else {
|
||||
config = NM_DHCP4_CONFIG (_nm_object_cache_get (path));
|
||||
if (config)
|
||||
config = g_object_ref (config);
|
||||
else {
|
||||
if (!config) {
|
||||
connection = nm_object_get_connection (object);
|
||||
config = NM_DHCP4_CONFIG (nm_dhcp4_config_new (connection, path));
|
||||
}
|
||||
|
|
@ -207,9 +203,7 @@ demarshal_ip6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
|
|||
priv->null_ip6_config = TRUE;
|
||||
else {
|
||||
config = NM_IP6_CONFIG (_nm_object_cache_get (path));
|
||||
if (config)
|
||||
config = g_object_ref (config);
|
||||
else {
|
||||
if (!config) {
|
||||
connection = nm_object_get_connection (object);
|
||||
config = NM_IP6_CONFIG (nm_ip6_config_new (connection, path));
|
||||
}
|
||||
|
|
@ -247,9 +241,7 @@ demarshal_dhcp6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoi
|
|||
priv->null_dhcp6_config = TRUE;
|
||||
else {
|
||||
config = NM_DHCP6_CONFIG (_nm_object_cache_get (path));
|
||||
if (config)
|
||||
config = g_object_ref (config);
|
||||
else {
|
||||
if (!config) {
|
||||
connection = nm_object_get_connection (object);
|
||||
config = NM_DHCP6_CONFIG (nm_dhcp6_config_new (connection, path));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,6 @@ _nm_object_cache_get (const char *path)
|
|||
|
||||
_init_cache ();
|
||||
object = g_hash_table_lookup (cache, path);
|
||||
return object;
|
||||
return object ? g_object_ref (object) : NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Returns referenced object from the cache */
|
||||
NMObject *_nm_object_cache_get (const char *path);
|
||||
void _nm_object_cache_add (NMObject *object);
|
||||
void _nm_object_cache_remove_by_object (NMObject *object);
|
||||
|
|
|
|||
|
|
@ -253,9 +253,9 @@ _nm_object_array_demarshal (GValue *value,
|
|||
|
||||
path = g_ptr_array_index (array, i);
|
||||
object = G_OBJECT (_nm_object_cache_get (path));
|
||||
if (object) {
|
||||
g_ptr_array_add (temp, g_object_ref (object));
|
||||
} else {
|
||||
if (object)
|
||||
g_ptr_array_add (temp, object);
|
||||
else {
|
||||
object = (*func) (connection, path);
|
||||
if (object)
|
||||
g_ptr_array_add (temp, object);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue