Commit c9f127b8 authored by Christoph Reiter's avatar Christoph Reiter 🐍

Remove GObject.Value.__del__

We can move this into tp_dealloc now.
Only call unset() in the slice allocate case since g_boxed_free() will
do it anyway.
parent 22656c4b
......@@ -209,10 +209,6 @@ class Value(GObjectModule.Value):
if py_value is not None:
self.set_value(py_value)
def __del__(self):
if self._free_on_dealloc and self.g_type != TYPE_INVALID:
self.unset()
def set_boxed(self, boxed):
# Workaround the introspection marshalers inability to know
# these methods should be marshaling boxed types. This is because
......
......@@ -38,14 +38,17 @@ static void
boxed_clear (PyGIBoxed *self)
{
gpointer boxed = pyg_boxed_get_ptr (self);
GType g_type = ((PyGBoxed *)self)->gtype;
if ( ( (PyGBoxed *) self)->free_on_dealloc && boxed != NULL) {
if (self->slice_allocated) {
if (g_type && g_type_is_a (g_type, G_TYPE_VALUE))
g_value_unset (boxed);
g_slice_free1 (self->size, boxed);
self->slice_allocated = FALSE;
self->size = 0;
} else {
g_boxed_free (((PyGBoxed *)self)->gtype, boxed);
g_boxed_free (g_type, boxed);
}
}
pyg_boxed_set_ptr (self, NULL);
......@@ -200,12 +203,6 @@ pygi_boxed_new (PyTypeObject *type,
return (PyObject *) self;
}
static PyObject *
boxed_get_free_on_dealloc(PyGIBoxed *self, void *closure)
{
return pygi_gboolean_to_py( ((PyGBoxed *)self)->free_on_dealloc );
}
/**
* pygi_boxed_copy_in_place:
*
......@@ -230,11 +227,6 @@ pygi_boxed_copy_in_place (PyGIBoxed *self)
pygboxed->free_on_dealloc = TRUE;
}
static PyGetSetDef pygi_boxed_getsets[] = {
{ "_free_on_dealloc", (getter)boxed_get_free_on_dealloc, (setter)0 },
{ NULL, 0, 0 }
};
static PyMethodDef boxed_methods[] = {
{ "_clear_boxed", (PyCFunction)boxed_clear_wrapper, METH_NOARGS },
{ NULL, NULL, 0 }
......@@ -253,7 +245,6 @@ pygi_boxed_register_types (PyObject *m)
PyGIBoxed_Type.tp_init = (initproc) boxed_init;
PyGIBoxed_Type.tp_dealloc = (destructor) boxed_dealloc;
PyGIBoxed_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE);
PyGIBoxed_Type.tp_getset = pygi_boxed_getsets;
PyGIBoxed_Type.tp_methods = boxed_methods;
if (PyType_Ready (&PyGIBoxed_Type) < 0)
......
......@@ -666,12 +666,6 @@ class TestGValue(unittest.TestCase):
value.set_value(42.0)
self.assertEqual(value.get_value(), 42)
def test_multi_del(self):
value = GObject.Value(str, 'foo_bar')
value.__del__()
value.__del__()
del value
def test_string(self):
value = GObject.Value(str, 'foo_bar')
self.assertEqual(value.g_type, GObject.TYPE_STRING)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment