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/matrix.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/matrix.c')
-rw-r--r-- | source/blender/python/api2_2x/matrix.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/source/blender/python/api2_2x/matrix.c b/source/blender/python/api2_2x/matrix.c index 6b90a3a6494..894643c5362 100644 --- a/source/blender/python/api2_2x/matrix.c +++ b/source/blender/python/api2_2x/matrix.c @@ -733,22 +733,19 @@ PyObject* Matrix_inv(MatrixObject *self) then call vector.multiply(vector, scalar_cast_as_vector)*/ static int Matrix_coerce(PyObject ** m1, PyObject ** m2) { - PyObject *coerced = NULL; - if(!MatrixObject_Check(*m2)) { - if(VectorObject_Check(*m2) || PyFloat_Check(*m2) || PyInt_Check(*m2) || + if(VectorObject_Check(*m2) || PyFloat_Check(*m2) || PyInt_Check(*m2) || PointObject_Check(*m2)) { - coerced = EXPP_incr_ret(*m2); - *m2 = newMatrixObject(NULL,3,3,Py_NEW); - ((MatrixObject*)*m2)->coerced_object = coerced; - }else{ - return EXPP_ReturnIntError(PyExc_TypeError, - "matrix.coerce(): unknown operand - can't coerce for numeric protocols\n"); - } + PyObject *coerced = EXPP_incr_ret(*m2); + *m2 = newMatrixObject(NULL,3,3,Py_NEW); + ((MatrixObject*)*m2)->coerced_object = coerced; + Py_INCREF (*m1); + return 0; } - EXPP_incr2(*m1, *m2); - return 0; + + return EXPP_ReturnIntError(PyExc_TypeError, + "matrix.coerce(): unknown operand - can't coerce for numeric protocols"); } -//-----------------PROTCOL DECLARATIONS-------------------------- +//-----------------PROTOCOL DECLARATIONS-------------------------- static PySequenceMethods Matrix_SeqMethods = { (inquiry) Matrix_len, /* sq_length */ (binaryfunc) 0, /* sq_concat */ @@ -908,6 +905,7 @@ PyObject *newMatrixObject(float *mat, int rowSize, int colSize, int type) } } else { //or if no arguments are passed return identity matrix Matrix_Identity(self); + Py_DECREF(self); } self->wrapped = Py_NEW; }else{ //bad type |