mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-23 19:24:38 +00:00
libnm-glib: fix some property-handling warnings
Fix handle_object_array_property() to deal with receiving an empty list correctly (rather than warning and leaving the property with its previous value still set). Also, add two more untracked properties that shouldn't be warned about (NMDevice:device-type and NMActiveConnection:vpn, both of which are only used at construct time).
This commit is contained in:
parent
7b9c728b85
commit
2c6bade5b9
|
@ -438,6 +438,10 @@ register_properties (NMActiveConnection *connection)
|
|||
{ NM_ACTIVE_CONNECTION_DEFAULT, &priv->is_default },
|
||||
{ NM_ACTIVE_CONNECTION_DEFAULT6, &priv->is_default6 },
|
||||
{ NM_ACTIVE_CONNECTION_MASTER, &priv->master },
|
||||
|
||||
/* not tracked after construction time */
|
||||
{ "vpn", NULL },
|
||||
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
|
|
|
@ -160,10 +160,9 @@ register_properties (NMDevice *device)
|
|||
{ NM_DEVICE_STATE_REASON, &priv->state, demarshal_state_reason },
|
||||
{ NM_DEVICE_ACTIVE_CONNECTION, &priv->active_connection, NULL, NM_TYPE_ACTIVE_CONNECTION },
|
||||
|
||||
/* The D-Bus interface has this property, but we don't; register
|
||||
* it so that handle_property_changed() doesn't complain.
|
||||
*/
|
||||
/* Properties that exist in D-Bus but that we don't track */
|
||||
{ "ip4-address", NULL },
|
||||
{ "device-type", NULL },
|
||||
|
||||
{ NULL },
|
||||
};
|
||||
|
|
|
@ -580,19 +580,12 @@ typedef struct {
|
|||
} ObjectCreatedData;
|
||||
|
||||
static void
|
||||
object_created (GObject *obj, gpointer user_data)
|
||||
object_property_complete (ObjectCreatedData *odata)
|
||||
{
|
||||
ObjectCreatedData *odata = user_data;
|
||||
NMObject *self = odata->self;
|
||||
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
|
||||
PropertyInfo *pi = odata->pi;
|
||||
|
||||
/* We assume that on error, the creator_func printed something */
|
||||
|
||||
odata->objects[--odata->remaining] = obj;
|
||||
if (odata->remaining)
|
||||
return;
|
||||
|
||||
if (odata->array) {
|
||||
GPtrArray **array = pi->field;
|
||||
int i;
|
||||
|
@ -623,6 +616,18 @@ object_created (GObject *obj, gpointer user_data)
|
|||
g_slice_free (ObjectCreatedData, odata);
|
||||
}
|
||||
|
||||
static void
|
||||
object_created (GObject *obj, gpointer user_data)
|
||||
{
|
||||
ObjectCreatedData *odata = user_data;
|
||||
|
||||
/* We assume that on error, the creator_func printed something */
|
||||
|
||||
odata->objects[--odata->remaining] = obj;
|
||||
if (!odata->remaining)
|
||||
object_property_complete (odata);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_object_property (NMObject *self, const char *property_name, GValue *value,
|
||||
PropertyInfo *pi, gboolean synchronously)
|
||||
|
@ -657,12 +662,12 @@ handle_object_property (NMObject *self, const char *property_name, GValue *value
|
|||
obj = _nm_object_create (pi->object_type, priv->connection, path);
|
||||
object_created (obj, odata);
|
||||
return obj != NULL;
|
||||
} else {
|
||||
_nm_object_create_async (pi->object_type, priv->connection, path,
|
||||
object_created, odata);
|
||||
/* Assume success */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
_nm_object_create_async (pi->object_type, priv->connection, path,
|
||||
object_created, odata);
|
||||
/* Assume success */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -675,7 +680,6 @@ handle_object_array_property (NMObject *self, const char *property_name, GValue
|
|||
GPtrArray **array = pi->field;
|
||||
const char *path;
|
||||
ObjectCreatedData *odata;
|
||||
gboolean add_to_reload = (priv->reload_results != NULL);
|
||||
int i;
|
||||
|
||||
paths = g_value_get_boxed (value);
|
||||
|
@ -688,6 +692,14 @@ handle_object_array_property (NMObject *self, const char *property_name, GValue
|
|||
odata->array = TRUE;
|
||||
odata->property_name = property_name;
|
||||
|
||||
if (priv->reload_results)
|
||||
priv->reload_remaining++;
|
||||
|
||||
if (paths->len == 0) {
|
||||
object_property_complete (odata);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; i < paths->len; i++) {
|
||||
path = paths->pdata[i];
|
||||
if (!strcmp (path, "/")) {
|
||||
|
@ -695,23 +707,16 @@ handle_object_array_property (NMObject *self, const char *property_name, GValue
|
|||
continue;
|
||||
}
|
||||
|
||||
if (add_to_reload) {
|
||||
priv->reload_remaining++;
|
||||
add_to_reload = FALSE;
|
||||
}
|
||||
|
||||
obj = G_OBJECT (_nm_object_cache_get (path));
|
||||
if (obj) {
|
||||
object_created (obj, odata);
|
||||
continue;
|
||||
} else if (synchronously) {
|
||||
obj = _nm_object_create (pi->object_type, priv->connection, path);
|
||||
object_created (obj, odata);
|
||||
continue;
|
||||
} else {
|
||||
_nm_object_create_async (pi->object_type, priv->connection, path,
|
||||
object_created, odata);
|
||||
}
|
||||
|
||||
_nm_object_create_async (pi->object_type, priv->connection, path,
|
||||
object_created, odata);
|
||||
}
|
||||
|
||||
if (!synchronously) {
|
||||
|
|
Loading…
Reference in a new issue