提交 8faa2f85 编写于 作者: P Peter Crosthwaite 提交者: Paolo Bonzini

qom: Demote already-has-a-parent to a regular error

Rather than an abort(). This allows callers to decide whether parenting
an already-parented object is a fatal error condition.

Useful for providing a default value for an object's parent in the case
where you want to set one iff it doesn't already have one.
Reviewed-by: NAlexander Graf <agraf@suse.de>
Signed-off-by: NPeter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 d3c49316
......@@ -1089,6 +1089,11 @@ void object_property_add_child(Object *obj, const char *name,
gchar *type;
ObjectProperty *op;
if (child->parent != NULL) {
error_setg(errp, "child object is already parented");
return;
}
type = g_strdup_printf("child<%s>", object_get_typename(OBJECT(child)));
op = object_property_add(obj, name, type, object_get_child_property, NULL,
......@@ -1100,7 +1105,6 @@ void object_property_add_child(Object *obj, const char *name,
op->resolve = object_resolve_child_property;
object_ref(child);
g_assert(child->parent == NULL);
child->parent = obj;
out:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册