diff options
Diffstat (limited to 'source/blender/freestyle/intern')
6 files changed, 8 insertions, 18 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp index 00f2aa7e0c6..88576ff5954 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.cpp +++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp @@ -322,10 +322,9 @@ PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs ) { return py_vs; } -PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m ){ +PyObject * BPy_FrsMaterial_from_FrsMaterial(const FrsMaterial& m) { PyObject *py_m = FrsMaterial_Type.tp_new( &FrsMaterial_Type, 0, 0 ); - ((BPy_FrsMaterial*) py_m)->m = &m; - ((BPy_FrsMaterial*) py_m)->borrowed = 1; + ((BPy_FrsMaterial*) py_m)->m = new FrsMaterial( m ); return py_m; } diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h index 6082d70695e..66689a55db3 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.h +++ b/source/blender/freestyle/intern/python/BPy_Convert.h @@ -88,7 +88,7 @@ PyObject * BPy_Id_from_Id( Id& id ); PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D ); PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D ); PyObject * BPy_IntegrationType_from_IntegrationType( IntegrationType i ); -PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m ); +PyObject * BPy_FrsMaterial_from_FrsMaterial(const FrsMaterial& m); PyObject * BPy_Nature_from_Nature( unsigned short n ); PyObject * BPy_MediumType_from_MediumType( Stroke::MediumType n ); PyObject * BPy_SShape_from_SShape( SShape& ss ); diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp index 153d454a720..8d651c702b0 100644 --- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp +++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp @@ -75,7 +75,7 @@ static int FrsMaterial_init(BPy_FrsMaterial *self, PyObject *args, PyObject *kwd PyErr_SetString(PyExc_RuntimeError, "invalid FrsMaterial object"); return -1; } - self->m = new FrsMaterial( *m ); + self->m = new FrsMaterial(*m); } else if (float_array_from_PyObject(obj1, f1, 4) && obj2 && float_array_from_PyObject(obj2, f2, 4) && obj3 && @@ -87,15 +87,13 @@ static int FrsMaterial_init(BPy_FrsMaterial *self, PyObject *args, PyObject *kwd PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); return -1; } - self->borrowed = 0; return 0; } static void FrsMaterial_dealloc(BPy_FrsMaterial* self) { - if (self->m && !self->borrowed) - delete self->m; + delete self->m; Py_TYPE(self)->tp_free((PyObject*)self); } diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h index d538024e6bb..b1b289458f5 100644 --- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.h +++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.h @@ -19,7 +19,6 @@ extern PyTypeObject FrsMaterial_Type; typedef struct { PyObject_HEAD FrsMaterial *m; - int borrowed; /* non-zero if *m is a borrowed object */ } BPy_FrsMaterial; /*---------------------------Python BPy_FrsMaterial visible prototypes-----------*/ diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp index aef1086a641..49da570a9fc 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp @@ -288,9 +288,7 @@ PyDoc_STRVAR(FEdgeSharp_material_right_doc, static PyObject *FEdgeSharp_material_right_get(BPy_FEdgeSharp *self, void *UNUSED(closure)) { - // FIXME aFrsMaterial() returns a const reference. - FrsMaterial m(self->fes->aFrsMaterial()); - return BPy_FrsMaterial_from_FrsMaterial(m); + return BPy_FrsMaterial_from_FrsMaterial(self->fes->aFrsMaterial()); } PyDoc_STRVAR(FEdgeSharp_material_left_doc, @@ -300,9 +298,7 @@ PyDoc_STRVAR(FEdgeSharp_material_left_doc, static PyObject *FEdgeSharp_material_left_get(BPy_FEdgeSharp *self, void *UNUSED(closure)) { - // FIXME bFrsMaterial() returns a const reference. - FrsMaterial m(self->fes->bFrsMaterial()); - return BPy_FrsMaterial_from_FrsMaterial(m); + return BPy_FrsMaterial_from_FrsMaterial(self->fes->bFrsMaterial()); } PyDoc_STRVAR(FEdgeSharp_face_mark_right_doc, diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp index abda2ca1179..847794c74c0 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp @@ -179,9 +179,7 @@ PyDoc_STRVAR(FEdgeSmooth_material_doc, static PyObject *FEdgeSmooth_material_get(BPy_FEdgeSmooth *self, void *UNUSED(closure)) { - // FIXME frs_material() returns a const reference. - FrsMaterial m(self->fes->frs_material()); - return BPy_FrsMaterial_from_FrsMaterial(m); + return BPy_FrsMaterial_from_FrsMaterial(self->fes->frs_material()); } PyDoc_STRVAR(FEdgeSmooth_face_mark_doc, |