RNA: require the enum flag is set before enum items are set
Failure to do this can cause the the property default to be incorrect and some sanity checks fail to run. Fail when an error if this isn't set. Ref !144133
This commit is contained in:
@@ -1569,6 +1569,25 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_,
|
||||
|
||||
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
|
||||
{
|
||||
switch (prop->type) {
|
||||
case PROP_ENUM: {
|
||||
/* In some cases the flag will have been set, ignore that case.*/
|
||||
if ((flag & PROP_ENUM_FLAG) && (prop->flag & PROP_ENUM_FLAG) == 0) {
|
||||
EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
|
||||
if (eprop->item) {
|
||||
StructRNA *srna = DefRNA.laststruct;
|
||||
CLOG_ERROR(&LOG,
|
||||
"\"%s.%s\", PROP_ENUM_FLAG must be set before setting items",
|
||||
srna->identifier,
|
||||
prop->identifier);
|
||||
DefRNA.error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
prop->flag |= flag;
|
||||
if (flag & PROP_ID_REFCOUNT) {
|
||||
prop->flag_internal |= PROP_INTERN_PTR_ID_REFCOUNT_FORCED;
|
||||
|
||||
Reference in New Issue
Block a user