Fix T56662: Autocomplete for texture slot Crash (in console).
That pointer can be NULL, RNA default string handling does not support that. (that whole uv_layer prop is quite nasty actually, since it does not own that string, always borrows it from some other data :((( ).
This commit is contained in:
parent
aa844ad676
commit
2ab1063616
Notes:
blender-bot
2023-02-14 19:26:36 +01:00
Referenced by issue blender/blender-addons#56662, Autocomplete for texture slot Crash (in console)
|
@ -435,6 +435,34 @@ void rna_mtex_texture_slots_clear(ID *self_id, struct bContext *C, ReportList *r
|
|||
WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C));
|
||||
}
|
||||
|
||||
static void rna_TexPaintSlot_uv_layer_get(PointerRNA *ptr, char *value)
|
||||
{
|
||||
TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
|
||||
|
||||
if (data->uvname != NULL) {
|
||||
BLI_strncpy_utf8(value, data->uvname, 64);
|
||||
}
|
||||
else {
|
||||
value[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
static int rna_TexPaintSlot_uv_layer_length(PointerRNA *ptr)
|
||||
{
|
||||
TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
|
||||
return data->uvname == NULL ? 0 : strlen(data->uvname);
|
||||
}
|
||||
|
||||
static void rna_TexPaintSlot_uv_layer_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
|
||||
|
||||
if (data->uvname != NULL) {
|
||||
BLI_strncpy_utf8(data->uvname, value, 64);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
static void rna_def_material_mtex(BlenderRNA *brna)
|
||||
|
@ -2216,6 +2244,8 @@ static void rna_def_tex_slot(BlenderRNA *brna)
|
|||
prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_maxlength(prop, 64); /* else it uses the pointer size! */
|
||||
RNA_def_property_string_sdna(prop, NULL, "uvname");
|
||||
RNA_def_property_string_funcs(prop, "rna_TexPaintSlot_uv_layer_get", "rna_TexPaintSlot_uv_layer_length",
|
||||
"rna_TexPaintSlot_uv_layer_set");
|
||||
RNA_def_property_ui_text(prop, "UV Map", "Name of UV map");
|
||||
RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Material_update");
|
||||
|
||||
|
|
Loading…
Reference in New Issue