From e10a86eef9f5df4afe18e68c69799b371189c568 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 22 Nov 2006 23:12:38 +0000 Subject: [PATCH] (Partial) fix for bug #5289: Crash using Shape Widget Wizard script, was an error in customdata copy. The script still throws a python error though, but that seems unrelated to this crash. --- source/blender/blenkernel/intern/customdata.c | 9 ++++----- source/blender/python/api2_2x/Mesh.c | 9 ++++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 34723a0b291..6d17e51517c 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -431,15 +431,12 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, flag = layer->flag & ~CD_FLAG_NOFREE; data = layer->data; - if (alloctype == CD_CALLOC) { + if (alloctype == CD_CALLOC || alloctype == CD_DUPLICATE) { CustomData_add_layer(dest, type, flag, NULL, totelem); } else if (alloctype == CD_REFERENCE) { CustomData_add_layer(dest, type, flag|CD_FLAG_NOFREE, data, totelem); } - else if (alloctype == CD_DUPLICATE) { - CustomData_add_layer(dest, type, flag, MEM_dupallocN(data), totelem); - } else if (alloctype == CD_DEFAULT) { data = CustomData_add_layer(dest, type, flag, NULL, totelem); if(typeInfo->set_default) @@ -447,8 +444,10 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, } } - CustomData_update_offsets(dest); + if (alloctype == CD_DUPLICATE) + CustomData_copy_data(source, dest, 0, 0, totelem); + CustomData_update_offsets(dest); } void CustomData_copy(const struct CustomData *source, struct CustomData *dest, diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index c30f974e457..195286cd695 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -1690,7 +1690,8 @@ static PyObject *MVertSeq_extend( BPy_MVertSeq * self, PyObject *args ) /* create custom vertex data arrays and copy existing vertices into it */ newlen = mesh->totvert + len; - CustomData_copy( &mesh->vdata, &vdata, CD_MASK_MESH, CD_DUPLICATE, newlen ); + CustomData_copy( &mesh->vdata, &vdata, CD_MASK_MESH, CD_CALLOC, newlen ); + CustomData_copy_data( &mesh->vdata, &vdata, 0, 0, mesh->totvert ); CustomData_set_default( &vdata, mesh->totvert, len ); if ( !CustomData_has_layer( &vdata, CD_MVERT ) ) @@ -2859,7 +2860,8 @@ static PyObject *MEdgeSeq_extend( BPy_MEdgeSeq * self, PyObject *args ) int totedge = mesh->totedge+good_edges; /* create custom edge data arrays and copy existing edges into it */ - CustomData_copy( &mesh->edata, &edata, CD_MASK_MESH, CD_DUPLICATE, totedge ); + CustomData_copy( &mesh->edata, &edata, CD_MASK_MESH, CD_CALLOC, totedge ); + CustomData_copy_data( &mesh->edata, &edata, 0, 0, mesh->totedge ); CustomData_set_default( &edata, mesh->totedge, good_edges ); if ( !CustomData_has_layer( &edata, CD_MEDGE ) ) @@ -4802,7 +4804,8 @@ static PyObject *MFaceSeq_extend( BPy_MEdgeSeq * self, PyObject *args, int totface = mesh->totface+good_faces; /* new face count */ CustomData fdata; - CustomData_copy( &mesh->fdata, &fdata, CD_MASK_MESH, CD_DUPLICATE, totface ); + CustomData_copy( &mesh->fdata, &fdata, CD_MASK_MESH, CD_CALLOC, totface ); + CustomData_copy_data( &mesh->fdata, &fdata, 0, 0, mesh->totface ); CustomData_set_default( &fdata, mesh->totface, good_faces ); if ( !CustomData_has_layer( &fdata, CD_MFACE ) )