qdev: Make qdev_class_add_property() more flexible
Support Property.set_default and PropertyInfo.description even if PropertyInfo.create is set. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20201211220529.2290218-26-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
f59c6d223d
commit
0d5d5bc58b
@ -863,24 +863,22 @@ static void qdev_class_add_property(DeviceClass *klass, const char *name,
|
|||||||
Property *prop)
|
Property *prop)
|
||||||
{
|
{
|
||||||
ObjectClass *oc = OBJECT_CLASS(klass);
|
ObjectClass *oc = OBJECT_CLASS(klass);
|
||||||
|
|
||||||
if (prop->info->create) {
|
|
||||||
prop->info->create(oc, name, prop);
|
|
||||||
} else {
|
|
||||||
ObjectProperty *op;
|
ObjectProperty *op;
|
||||||
|
|
||||||
|
if (prop->info->create) {
|
||||||
|
op = prop->info->create(oc, name, prop);
|
||||||
|
} else {
|
||||||
op = object_class_property_add(oc,
|
op = object_class_property_add(oc,
|
||||||
name, prop->info->name,
|
name, prop->info->name,
|
||||||
field_prop_getter(prop->info),
|
field_prop_getter(prop->info),
|
||||||
field_prop_setter(prop->info),
|
field_prop_setter(prop->info),
|
||||||
prop->info->release,
|
prop->info->release,
|
||||||
prop);
|
prop);
|
||||||
|
}
|
||||||
if (prop->set_default) {
|
if (prop->set_default) {
|
||||||
prop->info->set_default_value(op, prop);
|
prop->info->set_default_value(op, prop);
|
||||||
}
|
}
|
||||||
}
|
object_class_property_set_description(oc, name, prop->info->description);
|
||||||
object_class_property_set_description(oc, name,
|
|
||||||
prop->info->description);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user