creator.c wasn't updated in my last commit, here it is (the change reverts my previous change to it, since it was made unnecessary by handling onload scriptlinks a little differently, as can be checked in blender.c and editscreen.c).
- BPython: finishing object and nmesh .setMaterials commit, fixing two bugs. Also fixed a crash with object.track (pointer wasn't checked for validity). All based on reports and patch by Yann Vernier, thanks again.
This commit is contained in:
@@ -1835,26 +1835,26 @@ int EXPP_synchronizeMaterialLists (Object *object)
|
||||
{
|
||||
Material *** p_dataMaterials = give_matarar (object);
|
||||
short * nmaterials = give_totcolp (object);
|
||||
int result = 0;
|
||||
|
||||
if (object->totcol > *nmaterials) {
|
||||
/* More object mats than data mats */
|
||||
*nmaterials = object->totcol;
|
||||
return expandPtrArray ((void *) p_dataMaterials,
|
||||
result = expandPtrArray ((void *) p_dataMaterials,
|
||||
*nmaterials,
|
||||
object->totcol);
|
||||
*nmaterials = object->totcol;
|
||||
}
|
||||
else {
|
||||
if (object->totcol < *nmaterials) {
|
||||
/* More data mats than object mats */
|
||||
object->totcol = *nmaterials;
|
||||
return expandPtrArray ((void *) &object->mat,
|
||||
result = expandPtrArray ((void *) &object->mat,
|
||||
object->totcol,
|
||||
*nmaterials);
|
||||
object->totcol = *nmaterials;
|
||||
}
|
||||
}
|
||||
} /* else no synchronization needed, they are of equal length */
|
||||
|
||||
/* No synchronization is needed; they're of equal length */
|
||||
return 1;
|
||||
return result; /* 1 if changed, 0 otherwise */
|
||||
}
|
||||
|
||||
void EXPP_incr_mats_us (Material **matlist, int len)
|
||||
|
||||
@@ -818,7 +818,7 @@ static PyObject *NMesh_setMaterials (PyObject *self, PyObject *args)
|
||||
BPy_NMesh *me = (BPy_NMesh *)self;
|
||||
PyObject *pymats = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "O!", &PyList_Type, pymats))
|
||||
if (!PyArg_ParseTuple (args, "O!", &PyList_Type, &pymats))
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected a list of materials (None's also accepted) as argument");
|
||||
|
||||
|
||||
@@ -1570,21 +1570,21 @@ static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args)
|
||||
if ((len < 0) || (len > MAXMAT))
|
||||
{
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"illegal material index!"));
|
||||
"material list should have at least 1, at most 16 entries"));
|
||||
}
|
||||
|
||||
if (self->object->mat)
|
||||
{
|
||||
EXPP_releaseMaterialList (self->object->mat, len);
|
||||
EXPP_releaseMaterialList (self->object->mat, self->object->totcol);
|
||||
}
|
||||
/* Increase the user count on all materials */
|
||||
for (i=0 ; i<len ; i++)
|
||||
{
|
||||
id_us_plus ((ID *) matlist[i]);
|
||||
if (matlist[i]) id_us_plus ((ID *) matlist[i]);
|
||||
}
|
||||
self->object->mat = matlist;
|
||||
self->object->totcol = len;
|
||||
self->object->actcol = -1;
|
||||
self->object->actcol = len;
|
||||
|
||||
switch (self->object->type)
|
||||
{
|
||||
@@ -1993,6 +1993,8 @@ PyObject* Object_CreatePyObject (struct Object *obj)
|
||||
{
|
||||
BPy_Object * blen_object;
|
||||
|
||||
if (!obj) return EXPP_incr_ret (Py_None);
|
||||
|
||||
blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
|
||||
|
||||
if (blen_object == NULL)
|
||||
|
||||
Reference in New Issue
Block a user