Fix property tags dummy enum value holding a reference to stack memory

Also update the doc-string to include a warning about this.
This commit is contained in:
Campbell Barton 2023-06-29 10:29:14 +10:00
parent 65f40a4e5d
commit 09c0c86d83
2 changed files with 5 additions and 1 deletions

@ -384,6 +384,10 @@ void RNA_def_property_array(PropertyRNA *prop, int length);
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[]); void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[]);
void RNA_def_property_range(PropertyRNA *prop, double min, double max); void RNA_def_property_range(PropertyRNA *prop, double min, double max);
/**
* \param item: An array of enum properties terminated by null members.
* \warning take care not to reference stack memory as the reference to `item` is held by `prop`.
*/
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item); void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item);
void RNA_def_property_enum_native_type(PropertyRNA *prop, const char *native_enum_type); void RNA_def_property_enum_native_type(PropertyRNA *prop, const char *native_enum_type);
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength); void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength);

@ -2944,7 +2944,7 @@ static void rna_def_property(BlenderRNA *brna)
{ {
StructRNA *srna; StructRNA *srna;
PropertyRNA *prop; PropertyRNA *prop;
EnumPropertyItem dummy_prop_tags[] = { static const EnumPropertyItem dummy_prop_tags[] = {
{0, NULL, 0, NULL, NULL}, {0, NULL, 0, NULL, NULL},
}; };