Compiles with python 2.6

Fixed dangerous decref


git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1089 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
remi-k 2009-05-10 21:33:22 +00:00
parent 494c8e6d0f
commit 5240c80229
2 changed files with 6 additions and 6 deletions

View File

@ -39,10 +39,7 @@ extern PyTypeObject PySfDrawableType;
static void
PySfSprite_dealloc(PySfSprite *self)
{
if (self->Image != NULL)
{
Py_DECREF(self->Image);
}
Py_XDECREF(self->Image);
delete self->obj;
free_object(self);
}
@ -96,7 +93,7 @@ PySfSprite_SetImage(PySfSprite* self, PyObject *args)
PyErr_SetString(PyExc_TypeError, "Sprite.SetImage() Argument is not a sf.Image");
return NULL;
}
Py_DECREF(self->Image);
Py_CLEAR(self->Image);
Py_INCREF(Image);
self->Image = Image;
self->obj->SetImage(*(Image->obj));

View File

@ -53,12 +53,15 @@
#define load_from_file(self, args) \
return PyBool_FromLong(self->obj->LoadFromFile(PyString_AsString(args)))
#define Py_TYPE(a) a->ob_type
#define head_init PyObject_HEAD_INIT(NULL) 0,
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
#endif
#ifndef Py_TYPE
#define Py_TYPE(a) a->ob_type
#endif
#define free_object(a) Py_TYPE(a)->tp_free((PyObject*)a)
#define PyBool_AsBool(a) ((PyObject_IsTrue(a))?true:false)