diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-09-12 19:31:14 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-09-12 19:31:14 +0300 |
commit | 2ab1063616b9cab3ef74fd7f38ffa08cfb77f5d0 (patch) | |
tree | 4dc637620eb84d6d8828cf690c0373cae02536c2 /source/blender/makesrna/intern/rna_material.c | |
parent | aa844ad676d2e9d4f72f773fde64712c8a794e5e (diff) |
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 :((( ).
Diffstat (limited to 'source/blender/makesrna/intern/rna_material.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_material.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 4947557af10..5bd12d727ed 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -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"); |