[Bf-python] Proposed BPyAPI Additions.
Ken Hughes
khughes at pacific.edu
Mon Dec 11 19:22:14 CET 2006
Good discussion on IRC yesterday; unfortunately my system crashed
before I had a chance to save out the IRC session. Can anyone
summarize? How much needs to be done to clean up prior to 2.43?
Regarding fixing Object.New() to protect against objects with no obdata,
I can only see two solutions. (Note that if scn.link(ob) is done, there
is no problem). One is to catch ob->data whereever it's referenced
elsewhere in Blender and make sure it doesn't crash. I had put code in
Object_dealloc() earlier to at least delete the object if it wasn't
valid, and a check in unlink_object() to ignore ob->data == NULL, but
this isn't very robust. I also don't like changing the non-Py Blender
code to make up for an error caused by the Py Blender code.
The second solution is to internally treat all new objects as EMPTY
objects until data is linked to them. Object.New() stores the "real
type" in the Python object and when ob.link() is called it then copies
this into self->object->type prior to linking the obdata. If the object
never gets linked, then it either can delete the object from Blender's
database when Object_dealloc() is invoked or leave it as a harmless
EMPTY (because empty objects already have ob->date == NULL).
I dislike the second method, but less than the first. It doesn't
require any changes to any non-Py Blender code, and normal scripts won'd
notice the difference, but it has to play games with data to make
everything work.
Ken
More information about the Bf-python
mailing list