[Bf-blender-cvs] [2ab1063616b] master: Fix T56662: Autocomplete for texture slot Crash (in console).

Bastien Montagne noreply at git.blender.org
Wed Sep 12 18:32:33 CEST 2018


Commit: 2ab1063616b9cab3ef74fd7f38ffa08cfb77f5d0
Author: Bastien Montagne
Date:   Wed Sep 12 18:31:14 2018 +0200
Branches: master
https://developer.blender.org/rB2ab1063616b9cab3ef74fd7f38ffa08cfb77f5d0

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 :((( ).

===================================================================

M	source/blender/makesrna/intern/rna_material.c

===================================================================

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");



More information about the Bf-blender-cvs mailing list