[Bf-blender-cvs] [02685ac] gooseberry: Fix T43878: Applying non-constructive modifiers crashing blender

Sergey Sharybin noreply at git.blender.org
Wed Mar 4 14:08:32 CET 2015


Commit: 02685aca523857672dd3e3b4ba2423f08262812b
Author: Sergey Sharybin
Date:   Wed Mar 4 18:06:21 2015 +0500
Branches: gooseberry
https://developer.blender.org/rB02685aca523857672dd3e3b4ba2423f08262812b

Fix T43878: Applying non-constructive modifiers crashing blender

The issue was caused by recent DM to mesh conversion which was taking ownership,
and it was failing if there are any referenced layers in the custom data.

Now disable passing ownership if there are any referenced layers.

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

M	source/blender/blenkernel/BKE_customdata.h
M	source/blender/blenkernel/intern/DerivedMesh.c
M	source/blender/blenkernel/intern/customdata.c

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

diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index a5ccb50..6a0cfef 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -96,6 +96,11 @@ bool CustomData_has_math(const struct CustomData *data);
 bool CustomData_has_interp(const struct CustomData *data);
 bool CustomData_bmesh_has_free(const struct CustomData *data);
 
+/**
+ * Checks if any of the customdata layers is referenced.
+ */
+bool CustomData_has_referenced(const struct CustomData *data);
+
 /* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to
  * another, while not overwriting anything else (e.g. flags).  probably only
  * implemented for mloopuv/mloopcol, for now.*/
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 98d8ff9..dd12922 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -540,7 +540,15 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask, bool
 	int alloctype = CD_DUPLICATE;
 
 	if (take_ownership && dm->type == DM_TYPE_CDDM && dm->needsFree) {
-		alloctype = CD_ASSIGN;
+		bool has_any_referenced_layers =
+		        CustomData_has_referenced(&dm->vertData) ||
+		        CustomData_has_referenced(&dm->edgeData) ||
+		        CustomData_has_referenced(&dm->loopData) ||
+		        CustomData_has_referenced(&dm->faceData) ||
+		        CustomData_has_referenced(&dm->polyData);
+		if (!has_any_referenced_layers) {
+			alloctype = CD_ASSIGN;
+		}
 	}
 
 	CustomData_reset(&tmp.vdata);
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 6cda53f..149dc7c 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -2901,6 +2901,17 @@ bool CustomData_has_interp(const struct CustomData *data)
 	return false;
 }
 
+bool CustomData_has_referenced(const struct CustomData *data)
+{
+	int i;
+	for (i = 0; i < data->totlayer; ++i) {
+		if (data->layers[i].flag & CD_FLAG_NOFREE) {
+			return true;
+		}
+	}
+	return false;
+}
+
 /* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to
  * another, while not overwriting anything else (e.g. flags)*/
 void CustomData_data_copy_value(int type, const void *source, void *dest)




More information about the Bf-blender-cvs mailing list