[Bf-blender-cvs] [7e62314] soc-2013-paint: Fix possible crash:

Antony Riakiotakis noreply at git.blender.org
Fri Apr 25 22:46:59 CEST 2014


Commit: 7e62314aed8e1644c7bbeb5666520a5d7ffb17f4
Author: Antony Riakiotakis
Date:   Fri Apr 25 23:46:52 2014 +0300
https://developer.blender.org/rB7e62314aed8e1644c7bbeb5666520a5d7ffb17f4

Fix possible crash:

Could happen if user changes UV layer name from the mesh data properties
and has that uv layer assigned to a material slot.
In that case UV layer name is invalid and we could end up without UV
layers for drawing/painting.
Just reuse default UV layer in that case.

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

M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/gpu/intern/gpu_buffers.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 482ab12..3d2c159 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -3289,9 +3289,7 @@ static void project_paint_begin(ProjPaintState *ps)
 			continue;
 
 		if (slot != slot_last) {
-			if (slot->uvname[0])
-				tf_base = CustomData_get_layer_named(&ps->dm->faceData, CD_MTFACE, slot->uvname);
-			else
+			if (!slot->uvname[0] || !(tf_base = CustomData_get_layer_named(&ps->dm->faceData, CD_MTFACE, slot->uvname)))
 				tf_base = CustomData_get_layer(&ps->dm->faceData, CD_MTFACE);
 			slot_last = slot;
 		}
@@ -3311,9 +3309,7 @@ static void project_paint_begin(ProjPaintState *ps)
 			tf_clone = ps->dm_mtface_clone + face_index;
 
 			if (slot_clone != slot_last_clone) {
-				if (slot_clone->uvname[0])
-					tf_clone_base = CustomData_get_layer_named(&ps->dm->faceData, CD_MTFACE, slot_clone->uvname);
-				else
+				if (!slot_clone->uvname[0] || !(tf_clone_base = CustomData_get_layer_named(&ps->dm->faceData, CD_MTFACE, slot_clone->uvname)))
 					tf_clone_base = CustomData_get_layer(&ps->dm->faceData, CD_MTFACE);
 				slot_last_clone = slot_clone;
 			}
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 86837f0..64e0e4a 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -863,6 +863,10 @@ static void GPU_buffer_copy_uv_texpaint(DerivedMesh *dm, float *varray, int *ind
 		{
 			mtface_base[i] = CustomData_get_layer_named(&dm->faceData, CD_MTFACE,
 			                                            dm->mat[i]->texpaintslot[dm->mat[i]->paint_active_slot].uvname);
+			/* This can fail if we have changed the name in the UV layer list and have assigned the old name in the material
+			 * texture slot.*/
+			if (!mtface_base[i])
+				mtface_base[i] = CustomData_get_layer(&dm->faceData, CD_MTFACE);
 		}
 		else
 			mtface_base[i] = CustomData_get_layer(&dm->faceData, CD_MTFACE);




More information about the Bf-blender-cvs mailing list