diff options
author | Michel Selten <michel@mselten.demon.nl> | 2003-07-11 00:00:51 +0400 |
---|---|---|
committer | Michel Selten <michel@mselten.demon.nl> | 2003-07-11 00:00:51 +0400 |
commit | f999426daaf98c3abdb65ae6b78a9463ebcad0dd (patch) | |
tree | 95ed54d0c681ab04fc79f4cb4fee81807420e61b /source/blender/python/api2_2x/matrix.c | |
parent | 66e2bf39d975fe289b60f918f7e23157f22db1f6 (diff) |
* Object_getInverseMatrix now returns a correct matrix.
The problem was that the memory was allocated at the stack, but after the
Python object was created, the pointer to the memory goes invalid.
Thanks to Kester Maddoc for providing a patch - almost 2 weeks ago. Ouch,
I should read my mail a little bit better.
Diffstat (limited to 'source/blender/python/api2_2x/matrix.c')
-rw-r--r-- | source/blender/python/api2_2x/matrix.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/python/api2_2x/matrix.c b/source/blender/python/api2_2x/matrix.c index 6694ae8adab..76d4409dbad 100644 --- a/source/blender/python/api2_2x/matrix.c +++ b/source/blender/python/api2_2x/matrix.c @@ -39,6 +39,8 @@ static void Matrix_dealloc (MatrixObject *self) Py_DECREF (self->rows[2]); Py_DECREF (self->rows[3]); + if (self->mem) + PyMem_Free (self->mem); PyMem_DEL (self); } @@ -130,8 +132,16 @@ PyObject * newMatrixObject (float mat[][4]) MatrixObject * self; self = PyObject_NEW (MatrixObject, &Matrix_Type); - self->mat = mat; - + if (mat) + { + self->mem = NULL; + self->mat = mat; + } + else + { + self->mem = PyMem_Malloc (4*4*sizeof (float)); + self->mat = self->mem; + } self->rows[0] = newVectorObject ((float *)(self->mat[0]), 4); self->rows[1] = newVectorObject ((float *)(self->mat[1]), 4); self->rows[2] = newVectorObject ((float *)(self->mat[2]), 4); |