[libgovirt] resource: Update xml node in ovirt_resource_init_from_xml_real
- From: Eduardo de Barros Lima <eblima src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgovirt] resource: Update xml node in ovirt_resource_init_from_xml_real
- Date: Mon, 18 Sep 2017 13:18:57 +0000 (UTC)
commit c70b41e57797187b19a7b44f01a6d3eb05a9d1ff
Author: Christophe Fergeau <cfergeau redhat com>
Date: Mon Sep 11 14:59:08 2017 +0200
resource: Update xml node in ovirt_resource_init_from_xml_real
ovirt_resource_init_from_xml_real is called indirectly when
ovirt_resource_refresh() is used. For some reason, it updates
the various OvirtResource properties with the new XML node content, but
OvirtResource::xml-node is not set to be the new node.
This commit fixes this inconsistent state by making sure
OvirtResource::xml-node is changed to point to the new node.
govirt/ovirt-resource.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
index ad5e8ca..1984b1d 100644
--- a/govirt/ovirt-resource.c
+++ b/govirt/ovirt-resource.c
@@ -97,6 +97,15 @@ static void ovirt_resource_get_property(GObject *object,
}
}
+static void ovirt_resource_set_xml_node(OvirtResource *resource,
+ RestXmlNode *node)
+{
+ g_clear_pointer(&resource->priv->xml, &rest_xml_node_unref);
+ if (node != NULL) {
+ resource->priv->xml = rest_xml_node_ref(node);
+ }
+}
+
static void ovirt_resource_set_property(GObject *object,
guint prop_id,
const GValue *value,
@@ -121,13 +130,10 @@ static void ovirt_resource_set_property(GObject *object,
g_free(resource->priv->description);
resource->priv->description = g_value_dup_string(value);
break;
- case PROP_XML_NODE: {
- if (resource->priv->xml != NULL) {
- g_boxed_free(REST_TYPE_XML_NODE, resource->priv->xml);
- }
- resource->priv->xml = g_value_dup_boxed(value);
+ case PROP_XML_NODE:
+ ovirt_resource_set_xml_node(OVIRT_RESOURCE(object),
+ g_value_get_boxed(value));
break;
- }
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
@@ -438,6 +444,7 @@ static gboolean ovirt_resource_init_from_xml_real(OvirtResource *resource,
return FALSE;
}
+ ovirt_resource_set_xml_node(resource, node);
g_object_set(G_OBJECT(resource), "guid", guid, "href", href, NULL);
ovirt_resource_set_name_from_xml(resource, node);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]