Commit 2c6bade5 authored by Dan Winship's avatar Dan Winship
Browse files

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).
parent 7b9c728b
...@@ -438,6 +438,10 @@ register_properties (NMActiveConnection *connection) ...@@ -438,6 +438,10 @@ register_properties (NMActiveConnection *connection)
{ NM_ACTIVE_CONNECTION_DEFAULT, &priv->is_default }, { NM_ACTIVE_CONNECTION_DEFAULT, &priv->is_default },
{ NM_ACTIVE_CONNECTION_DEFAULT6, &priv->is_default6 }, { NM_ACTIVE_CONNECTION_DEFAULT6, &priv->is_default6 },
{ NM_ACTIVE_CONNECTION_MASTER, &priv->master }, { NM_ACTIVE_CONNECTION_MASTER, &priv->master },
/* not tracked after construction time */
{ "vpn", NULL },
{ NULL }, { NULL },
}; };
......
...@@ -160,10 +160,9 @@ register_properties (NMDevice *device) ...@@ -160,10 +160,9 @@ register_properties (NMDevice *device)
{ NM_DEVICE_STATE_REASON, &priv->state, demarshal_state_reason }, { NM_DEVICE_STATE_REASON, &priv->state, demarshal_state_reason },
{ NM_DEVICE_ACTIVE_CONNECTION, &priv->active_connection, NULL, NM_TYPE_ACTIVE_CONNECTION }, { NM_DEVICE_ACTIVE_CONNECTION, &priv->active_connection, NULL, NM_TYPE_ACTIVE_CONNECTION },
/* The D-Bus interface has this property, but we don't; register /* Properties that exist in D-Bus but that we don't track */
* it so that handle_property_changed() doesn't complain.
*/
{ "ip4-address", NULL }, { "ip4-address", NULL },
{ "device-type", NULL },
{ NULL }, { NULL },
}; };
......
...@@ -580,19 +580,12 @@ typedef struct { ...@@ -580,19 +580,12 @@ typedef struct {
} ObjectCreatedData; } ObjectCreatedData;
static void static void
object_created (GObject *obj, gpointer user_data) object_property_complete (ObjectCreatedData *odata)
{ {
ObjectCreatedData *odata = user_data;
NMObject *self = odata->self; NMObject *self = odata->self;
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self); NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
PropertyInfo *pi = odata->pi; 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) { if (odata->array) {
GPtrArray **array = pi->field; GPtrArray **array = pi->field;
int i; int i;
...@@ -623,6 +616,18 @@ object_created (GObject *obj, gpointer user_data) ...@@ -623,6 +616,18 @@ object_created (GObject *obj, gpointer user_data)
g_slice_free (ObjectCreatedData, odata); 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 static gboolean
handle_object_property (NMObject *self, const char *property_name, GValue *value, handle_object_property (NMObject *self, const char *property_name, GValue *value,
PropertyInfo *pi, gboolean synchronously) PropertyInfo *pi, gboolean synchronously)
...@@ -657,12 +662,12 @@ handle_object_property (NMObject *self, const char *property_name, GValue *value ...@@ -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); obj = _nm_object_create (pi->object_type, priv->connection, path);
object_created (obj, odata); object_created (obj, odata);
return obj != NULL; 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 static gboolean
...@@ -675,7 +680,6 @@ handle_object_array_property (NMObject *self, const char *property_name, GValue ...@@ -675,7 +680,6 @@ handle_object_array_property (NMObject *self, const char *property_name, GValue
GPtrArray **array = pi->field; GPtrArray **array = pi->field;
const char *path; const char *path;
ObjectCreatedData *odata; ObjectCreatedData *odata;
gboolean add_to_reload = (priv->reload_results != NULL);
int i; int i;
paths = g_value_get_boxed (value); paths = g_value_get_boxed (value);
...@@ -688,6 +692,14 @@ handle_object_array_property (NMObject *self, const char *property_name, GValue ...@@ -688,6 +692,14 @@ handle_object_array_property (NMObject *self, const char *property_name, GValue
odata->array = TRUE; odata->array = TRUE;
odata->property_name = property_name; 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++) { for (i = 0; i < paths->len; i++) {
path = paths->pdata[i]; path = paths->pdata[i];
if (!strcmp (path, "/")) { if (!strcmp (path, "/")) {
...@@ -695,23 +707,16 @@ handle_object_array_property (NMObject *self, const char *property_name, GValue ...@@ -695,23 +707,16 @@ handle_object_array_property (NMObject *self, const char *property_name, GValue
continue; continue;
} }
if (add_to_reload) {
priv->reload_remaining++;
add_to_reload = FALSE;
}
obj = G_OBJECT (_nm_object_cache_get (path)); obj = G_OBJECT (_nm_object_cache_get (path));
if (obj) { if (obj) {
object_created (obj, odata); object_created (obj, odata);
continue;
} else if (synchronously) { } else if (synchronously) {
obj = _nm_object_create (pi->object_type, priv->connection, path); obj = _nm_object_create (pi->object_type, priv->connection, path);
object_created (obj, odata); 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) { if (!synchronously) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment