Blame SOURCES/0031-resource-Update-xml-node-in-ovirt_resource_init_from.patch

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