[Bf-python] Bug plus suggested fix
Jonathan Thambidurai
jonthambi at comcast.net
Sat Jun 21 23:27:17 CEST 2003
The python code at the end of this message, after several subsequent,
consecutive runs (or even on the first run sometimes), results in a
segfault. As you can see, the problem lies with Object.getParent(). If
you look at this function (in the C code), you will see that it relies
on the "non-nullness" of the self->parent pointer; this pointer, however
is not initialized to zero in the M_Object_Get() C function, resulting
in the random failure of getParent() of objects that are not created by
M_Object_New(). The first attached patch (fix.patch) fixes this. Allow
me also suggest that we do return Py_None in object.getParent() if an
object has no parent. The second attached patch (enhance.patch) does
this and also fixes the NULL pointer problem.
--Jonathan Thambidurai
--------------------------------------------------------------------
from Blender import *
objectname_list = Object.get()
#file = sys.stdout
file = open( "/home/jonathan/tmp/testjglblend", "w" );
for object_name in objectname_list:
object = Object.get( object_name )
if object.getType() == "Mesh":
# mesh = object.getData()
# file.write( "MESH\n" )
# file.write( repr( object ) + "\n" )
parent = object.getParent()
# if parent != None:
# file.write( repr( object.getParent() ) + "\n" )
# else:
# file.write( "noparent" )
# #material_list = object.getMaterials()
# #file.write( str( len( material_list ) ) + "\n" )
# #for material in material_list:
# # file.write( material.getName() + "\n" );
# #testing texture coords
# mesh_verts = mesh.verts
# for vertex in mesh_verts:
# file.write( repr( vertex ) )
# file.write( "co: " + repr( vertex.co ) + "\n" )
# file.write( "no: " + repr( vertex.no ) + "\n" )
# file.write( "uvco: " + repr( vertex.uvco ) + "\n" )
# file.write( "index: " + repr( vertex.index) + "\n" )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix.patch
Type: text/x-patch
Size: 550 bytes
Desc:
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20030621/9798a59b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: enhance.patch
Type: text/x-patch
Size: 830 bytes
Desc:
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20030621/9798a59b/attachment-0001.bin>
More information about the Bf-python
mailing list