[Bf-committers] 2 small bugfixes for NMesh

Alexander Szakaly alexander.szakaly at vct.se
Wed Nov 3 10:49:28 CET 2004


Hi,

I am new on this mailinglist and I just started looking at the blender code
this sunday.
I had very frequent crashes when using Fiber 2.03 with Blender 2.34 so I
started looking at the code to find the problem. 

The crash occurs if you have a mesh in your scene with some name (e.g.
"theMesh") with a material assigned to it and then from a python script
create a new mesh with no materials and do NMesh.PutRaw("theMesh").

Actually I found two bugs that are fixed with this patch (the patch is made
against a fresh CVS checkout).
1. In EXPP_newMaterialList_fromPyList in
source/blender/python/api2_2x/Material.c: If the MaterialList of the nmesh
is empty then the function will still call EXPP_newMaterialList(0) which
basically leads to a call to MEM_calloc that only allocates head and tail
without any place for the struct and still a valid pointer is returned (so
everything looks ok for the caller). I would have liked to add the check for
zero length allocations in the memory allocation routines in MEM but added a
quickfix here instead. 

2. In EXPP_unlink_mesh in source/blender/python/api2_2x/NMesh.c:
All materials are unlinked from the mesh but me->totcol is not reset to
zero.

Anyway, the patch only contains two added lines so it is not much but it
took me some time to sort this out because I had to go through a lot of code
just to learn the insides of blender. You should probably review the patch
extra carefully just to make sure I haven't screwed something up...

That’s all for now folks...

// Alexander Szakaly (bagge)
//    alexander.szakaly at vct.se

-------------- next part --------------
A non-text attachment was scrubbed...
Name: nmesh_bugfix.patch
Type: application/octet-stream
Size: 1603 bytes
Desc: not available
Url : http://projects.blender.org/pipermail/bf-committers/attachments/20041103/fdfd727c/nmesh_bugfix.obj


More information about the Bf-committers mailing list