diff options
author | Ken Hughes <khughes@pacific.edu> | 2005-12-05 22:02:30 +0300 |
---|---|---|
committer | Ken Hughes <khughes@pacific.edu> | 2005-12-05 22:02:30 +0300 |
commit | e209676d3d55c3d6a4e2fffd97cbd448a7bb556b (patch) | |
tree | a18cba90c2855c29eef1c4e7895a8b95793e8b65 /source/blender/python/api2_2x/quat.c | |
parent | f98a5a80366c5307e3a286c102a6dc804b778a42 (diff) |
-- Bugfix 3453: coercion operations were doing an extra incref on coerced
objects. Also found extra increfs on some newly-created quat and matrix
objects, from calls to Matrix_Identity() and Quaternion_Identity().
Diffstat (limited to 'source/blender/python/api2_2x/quat.c')
-rw-r--r-- | source/blender/python/api2_2x/quat.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/source/blender/python/api2_2x/quat.c b/source/blender/python/api2_2x/quat.c index 3c7cb4b839a..1cd07b0f588 100644 --- a/source/blender/python/api2_2x/quat.c +++ b/source/blender/python/api2_2x/quat.c @@ -518,23 +518,19 @@ static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2) then call vector.multiply(vector, scalar_cast_as_vector)*/ static int Quaternion_coerce(PyObject ** q1, PyObject ** q2) { - PyObject *coerced = NULL; - - if(!QuaternionObject_Check(*q2)) { - if(VectorObject_Check(*q2) || PyFloat_Check(*q2) || PyInt_Check(*q2) || + if(VectorObject_Check(*q2) || PyFloat_Check(*q2) || PyInt_Check(*q2) || PointObject_Check(*q2)) { - coerced = EXPP_incr_ret(*q2); - *q2 = newQuaternionObject(NULL,Py_NEW); - ((QuaternionObject*)*q2)->coerced_object = coerced; - }else{ - return EXPP_ReturnIntError(PyExc_TypeError, - "quaternion.coerce(): unknown operand - can't coerce for numeric protocols\n"); - } + PyObject *coerced = EXPP_incr_ret(*q2); + *q2 = newQuaternionObject(NULL,Py_NEW); + ((QuaternionObject*)*q2)->coerced_object = coerced; + Py_INCREF (*q1); + return 0; } - EXPP_incr2(*q1, *q2); - return 0; + + return EXPP_ReturnIntError(PyExc_TypeError, + "quaternion.coerce(): unknown operand - can't coerce for numeric protocols"); } -//-----------------PROTCOL DECLARATIONS-------------------------- +//-----------------PROTOCOL DECLARATIONS-------------------------- static PySequenceMethods Quaternion_SeqMethods = { (inquiry) Quaternion_len, /* sq_length */ (binaryfunc) 0, /* sq_concat */ @@ -646,6 +642,7 @@ PyObject *newQuaternionObject(float *quat, int type) self->quat = self->data.py_data; if(!quat) { //new empty Quaternion_Identity(self); + Py_DECREF(self); }else{ for(x = 0; x < 4; x++){ self->quat[x] = quat[x]; |