From d3338620b710ae6575aef6cbb90ae61cbc9f586a Mon Sep 17 00:00:00 2001 From: Ken Hughes Date: Tue, 13 Dec 2005 18:39:50 +0000 Subject: [PATCH] -- More of Bugfix #3580: Mesh_getFromObject() was not updating key->from when it duplicated mesh data. I'm not thrilled with how I implemented this code, but currently don't know a better way. If someone more familiar with how blender duplicates objects and converts things to meshes wants to have a look, it would be appreciated. --- source/blender/python/api2_2x/Mesh.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index 49ab0fe603b..ec5d75f16df 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -4854,13 +4854,18 @@ static PyObject *Mesh_getFromObject( BPy_Mesh * self, PyObject * args ) /* save a copy of our ID, dup the temporary mesh, restore the ID */ tmpid = self->mesh->id; memcpy( self->mesh, tmpmesh, sizeof( Mesh ) ); - self->mesh->id= tmpid; + self->mesh->id = tmpid; + + /* if mesh has keys, make sure they point back to this mesh */ + if( self->mesh->key ) + self->mesh->key->from = (ID *)self->mesh; + /* remove the temporary mesh */ BLI_remlink( &G.main->mesh, tmpmesh ); MEM_freeN( tmpmesh ); /* make sure materials get updated in objects */ - test_object_materials( ( ID * ) self->mesh ); + test_object_materials( ( ID * ) self->mesh ); mesh_update( self->mesh ); return EXPP_incr_ret( Py_None );