revert part of own commit r35117 which modified mathutils initialization functions, found this could be done in a better way which doesnt have to deal with partly initialize instances being freed.
This commit is contained in:
@@ -642,32 +642,6 @@ PyTypeObject euler_Type = {
|
||||
(i.e. it was allocated elsewhere by MEM_mallocN())
|
||||
pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
|
||||
(i.e. it must be created here with PyMEM_malloc())*/
|
||||
static int newEulerObject_init(EulerObject *self, float *eul, short order, int type)
|
||||
{
|
||||
if(type == Py_WRAP) {
|
||||
self->eul = eul;
|
||||
self->wrapped = Py_WRAP;
|
||||
}
|
||||
else if (type == Py_NEW){
|
||||
self->eul = PyMem_Malloc(EULER_SIZE * sizeof(float));
|
||||
if(eul) {
|
||||
copy_v3_v3(self->eul, eul);
|
||||
}
|
||||
else {
|
||||
zero_v3(self->eul);
|
||||
}
|
||||
self->wrapped = Py_NEW;
|
||||
}
|
||||
else{
|
||||
PyErr_SetString(PyExc_RuntimeError, "invalid type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
self->order= order;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject *newEulerObject(float *eul, short order, int type, PyTypeObject *base_type)
|
||||
{
|
||||
EulerObject *self;
|
||||
@@ -675,14 +649,32 @@ PyObject *newEulerObject(float *eul, short order, int type, PyTypeObject *base_t
|
||||
self= base_type ? (EulerObject *)base_type->tp_alloc(base_type, 0) :
|
||||
(EulerObject *)PyObject_GC_New(EulerObject, &euler_Type);
|
||||
|
||||
/* init callbacks as NULL */
|
||||
self->cb_user= NULL;
|
||||
self->cb_type= self->cb_subtype= 0;
|
||||
((BaseMathObject *)self)->data= NULL; /* incase of error */
|
||||
if(self) {
|
||||
/* init callbacks as NULL */
|
||||
self->cb_user= NULL;
|
||||
self->cb_type= self->cb_subtype= 0;
|
||||
|
||||
if(newEulerObject_init(self, eul, order, type) == -1) {
|
||||
Py_DECREF(self);
|
||||
return NULL;
|
||||
if(type == Py_WRAP) {
|
||||
self->eul = eul;
|
||||
self->wrapped = Py_WRAP;
|
||||
}
|
||||
else if (type == Py_NEW) {
|
||||
self->eul = PyMem_Malloc(EULER_SIZE * sizeof(float));
|
||||
if(eul) {
|
||||
copy_v3_v3(self->eul, eul);
|
||||
}
|
||||
else {
|
||||
zero_v3(self->eul);
|
||||
}
|
||||
|
||||
self->wrapped = Py_NEW;
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Euler(): invalid type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
self->order= order;
|
||||
}
|
||||
|
||||
return (PyObject *)self;
|
||||
@@ -690,19 +682,12 @@ PyObject *newEulerObject(float *eul, short order, int type, PyTypeObject *base_t
|
||||
|
||||
PyObject *newEulerObject_cb(PyObject *cb_user, short order, int cb_type, int cb_subtype)
|
||||
{
|
||||
EulerObject *self;
|
||||
|
||||
self= (EulerObject *)PyObject_GC_New(VectorObject, &vector_Type);
|
||||
|
||||
Py_INCREF(cb_user);
|
||||
self->cb_user= cb_user;
|
||||
self->cb_type= (unsigned char)cb_type;
|
||||
self->cb_subtype= (unsigned char)cb_subtype;
|
||||
((BaseMathObject *)self)->data= NULL; /* incase of error */
|
||||
|
||||
if(newEulerObject_init(self, NULL, order, Py_NEW) == -1) {
|
||||
Py_DECREF(self);
|
||||
return NULL;
|
||||
EulerObject *self= (EulerObject *)newEulerObject(NULL, order, Py_NEW, NULL);
|
||||
if(self) {
|
||||
Py_INCREF(cb_user);
|
||||
self->cb_user= cb_user;
|
||||
self->cb_type= (unsigned char)cb_type;
|
||||
self->cb_subtype= (unsigned char)cb_subtype;
|
||||
}
|
||||
|
||||
return (PyObject *)self;
|
||||
|
Reference in New Issue
Block a user