[Bf-python] EditBone Safty

Gilbert, Joseph T. jgilbert at tigr.ORG
Wed Jul 26 16:51:22 CEST 2006


Yea I see what your saying. I think it's a good idea:

When Armature.update() is called, all EditBones in EditBonesDict will
receive a flag value that will be checked to see whether or not they can
be accessed.

However, the same should be true for regular Bones after calling
MakeEditable().

Just and idea you can explore:
tp_getattro gets called before any of the tp_methods are accessed. I
think this is because the default tp_getattro points to
PyObject_GenericGetAttr(). You could override tp_getattro to check the
flag before returning the method of the methods table....

Maybe something like:
static PyObject *
mytype_getattro(mytypeobject *self, PyObject *name)
{
    PyObject *tmp;

    if (!(tmp = PyObject_GenericGetAttr((PyObject *)self, name))) {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            return NULL;
        PyErr_Clear();
    }else{
        if (check_flag()){
            return return EXPP_ReturnPyObjError(PyExc_ValueError, "Can't
call this item" );
        }else{
            return tmp;
        }
    }

    .......
}

Just a thought.

-----Original Message-----
From: Campbell Barton [mailto:cbarton at metavr.com] 
Sent: Wednesday, July 26, 2006 2:55 AM
To: Gilbert, Joseph T.
Cc: Blender Foundation Python list
Subject: Re: [Bf-python] EditBone Safty

Can we have the create editbone function, add to a list (stored in the 
armature, but not seen by the user)
when update is called, all these python bones can have a  a property set

taht will raise an error if they are accsessed.

- Cam

Gilbert, Joseph T. wrote:
> Yes I agree. However I bet this is a more complex issue than it first
> appears....
>
> Because editbones wrap editbone data directly, and that data is freed
> upon calling update(). Python will still maintain a reference to the
> python object but it's underlying data is corrupt because it was
freed.
>
> Your issue here (I'm assuming) will be to somehow delete the python
> object from the script's __dict__ so that it can't be called (because
> the python object is now invalid).  
>
> Anyway without looking at the code, I have a feeling this may be the
> case.
>
> -----Original Message-----
> From: bf-python-bounces at projects.blender.org
> [mailto:bf-python-bounces at projects.blender.org] On Behalf Of Campbell
> Barton
> Sent: Sunday, July 23, 2006 9:46 PM
> To: Blender Foundation Python list
> Subject: [Bf-python] EditBone Safty
>
> Hi, was using the armatuer module and noticed that you can still
access 
> previously created even though you have exited editMode - with 
> arm_data.update()
>
> It should brobably raise an error if you access an EditBone out of 
> editmode so no memory errors happen,
> The only reason I noticed this is that the edit_bone.name  value
became 
> correupt
>
> - Ca,
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python
>
>   


-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241



More information about the Bf-python mailing list