fixed the bug Joseph Gilbert found in numerous python files.
newly created data objs had incorrect user counts.
This commit is contained in:
@@ -52,8 +52,12 @@ static PyObject *M_Armature_New(PyObject *self, PyObject *args,
|
||||
"expected string(s) or empty argument"));
|
||||
|
||||
bl_armature = add_armature(); /* first create in Blender */
|
||||
if (bl_armature) /* now create the wrapper obj in Python */
|
||||
if (bl_armature){
|
||||
/* return user count to zero because add_armature() inc'd it */
|
||||
bl_armature->id.us = 0;
|
||||
/* now create the wrapper obj in Python */
|
||||
py_armature = (BPy_Armature *)PyObject_NEW(BPy_Armature, &Armature_Type);
|
||||
}
|
||||
else
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't create Armature Data in Blender"));
|
||||
|
||||
@@ -44,20 +44,23 @@ static PyObject *M_Curve_New(PyObject *self, PyObject *args)
|
||||
Curve *blcurve = 0; /* for actual Curve Data we create in Blender */
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|s", &name))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected string argument or no argument"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected string argument or no argument"));
|
||||
|
||||
blcurve = add_curve(OB_CURVE); /* first create the Curve Data in Blender */
|
||||
if (blcurve == NULL)
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't create Curve Data in Blender"));
|
||||
|
||||
if (blcurve == NULL) /* bail out if add_curve() failed */
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't create Curve Data in Blender"));
|
||||
|
||||
/* return user count to zero because add_curve() inc'd it */
|
||||
blcurve->id.us = 0;
|
||||
/* create python wrapper obj */
|
||||
pycurve = (BPy_Curve *)PyObject_NEW(BPy_Curve, &Curve_Type);
|
||||
|
||||
|
||||
if (pycurve == NULL)
|
||||
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||
"couldn't create Curve Data object"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||
"couldn't create Curve Data object"));
|
||||
|
||||
pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */
|
||||
if (name)
|
||||
|
||||
@@ -45,19 +45,27 @@ static PyObject *M_Ipo_New(PyObject *self, PyObject *args)
|
||||
BPy_Ipo *pyipo;
|
||||
Ipo *blipo;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ss", &code,&name))
|
||||
if (!PyArg_ParseTuple(args, "ss", &code,&name))
|
||||
return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected string int arguments"));
|
||||
if (!strcmp(code,"Object"))idcode = ID_OB;
|
||||
if (!strcmp(code,"Camera"))idcode = ID_CA;
|
||||
if (!strcmp(code,"World"))idcode = ID_WO;
|
||||
if (!strcmp(code,"Material"))idcode = ID_MA;
|
||||
if (idcode == -1)
|
||||
|
||||
if (!strcmp(code,"Object"))idcode = ID_OB;
|
||||
if (!strcmp(code,"Camera"))idcode = ID_CA;
|
||||
if (!strcmp(code,"World"))idcode = ID_WO;
|
||||
if (!strcmp(code,"Material"))idcode = ID_MA;
|
||||
|
||||
if (idcode == -1)
|
||||
return (EXPP_ReturnPyObjError (PyExc_TypeError,"Bad code"));
|
||||
printf("%d %d %d \n", ID_OB, ID_CA, ID_WO);
|
||||
|
||||
printf("%d %d %d \n", ID_OB, ID_CA, ID_WO);
|
||||
|
||||
blipo = add_ipo(name,idcode);
|
||||
|
||||
if (blipo)
|
||||
pyipo = (BPy_Ipo *)PyObject_NEW(BPy_Ipo, &Ipo_Type);
|
||||
if (blipo){
|
||||
/* return user count to zero because add_ipo() inc'd it */
|
||||
blipo->id.us = 0;
|
||||
/* create python wrapper obj */
|
||||
pyipo = (BPy_Ipo *)PyObject_NEW(BPy_Ipo, &Ipo_Type);
|
||||
}
|
||||
else
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't create Ipo Data in Blender"));
|
||||
|
||||
@@ -76,8 +76,12 @@ static PyObject *M_Metaball_New(PyObject *self, PyObject *args)
|
||||
|
||||
blmball = add_mball(); /* first create the MetaBall Data in Blender */
|
||||
|
||||
if (blmball) /* now create the wrapper obj in Python */
|
||||
if (blmball){
|
||||
/* return user count to zero since add_mball() incref'ed it */
|
||||
blmball->id.us = 0;
|
||||
/* now create the wrapper obj in Python */
|
||||
pymball = (BPy_Metaball *)PyObject_NEW(BPy_Metaball, &Metaball_Type);
|
||||
}
|
||||
else
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't create MetaBall Data in Blender"));
|
||||
|
||||
@@ -229,8 +229,12 @@ static PyObject *M_Scene_New(PyObject *self, PyObject *args, PyObject *kword)
|
||||
|
||||
blscene = add_scene(name); /* first create the Scene in Blender */
|
||||
|
||||
if (blscene) /* now create the wrapper obj in Python */
|
||||
pyscene = Scene_CreatePyObject (blscene);
|
||||
if (blscene){
|
||||
/* return user count to zero because add_scene() inc'd it */
|
||||
blscene->id.us = 0;
|
||||
/* now create the wrapper obj in Python */
|
||||
pyscene = Scene_CreatePyObject (blscene);
|
||||
}
|
||||
else
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't create Scene obj in Blender"));
|
||||
|
||||
@@ -49,8 +49,12 @@ static PyObject *M_Text_New(PyObject *self, PyObject *args, PyObject *keywords)
|
||||
|
||||
bl_text = add_empty_text();
|
||||
|
||||
if (bl_text)
|
||||
if (bl_text) {
|
||||
/* return user count to zero because add_empty_text() inc'd it */
|
||||
bl_text->id.us = 0;
|
||||
/* create python wrapper obj */
|
||||
py_text = Text_CreatePyObject (bl_text);
|
||||
}
|
||||
else
|
||||
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't create Text Object in Blender");
|
||||
|
||||
@@ -116,13 +116,17 @@ static PyObject *M_World_New(PyObject *self, PyObject *args, PyObject *kwords)
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s", &name))
|
||||
return (EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected int argument"));
|
||||
"expected int argument"));
|
||||
|
||||
|
||||
blworld = add_world(name);
|
||||
|
||||
if (blworld)
|
||||
pyworld = (BPy_World *)PyObject_NEW(BPy_World, &World_Type);
|
||||
if (blworld){
|
||||
/* return user count to zero because add_world() inc'd it */
|
||||
blworld->id.us = 0;
|
||||
/* create python wrapper obj */
|
||||
pyworld = (BPy_World *)PyObject_NEW(BPy_World, &World_Type);
|
||||
}
|
||||
else
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't create World Data in Blender"));
|
||||
|
||||
Reference in New Issue
Block a user