[pygobject/gi-boxed-remove-del] Remove GObject.Value.__del__
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/gi-boxed-remove-del] Remove GObject.Value.__del__
- Date: Tue, 15 Jan 2019 15:43:54 +0000 (UTC)
commit c9f127b8121f3a94eb07bb6e1c95f6f01abe8cb2
Author: Christoph Reiter <reiter christoph gmail com>
Date: Tue Jan 15 15:38:20 2019 +0100
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.
gi/overrides/GObject.py | 4 ----
gi/pygi-boxed.c | 17 ++++-------------
tests/test_gobject.py | 6 ------
3 files changed, 4 insertions(+), 23 deletions(-)
---
diff --git a/gi/overrides/GObject.py b/gi/overrides/GObject.py
index 4df27ab3..938a19a8 100644
--- a/gi/overrides/GObject.py
+++ b/gi/overrides/GObject.py
@@ -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
diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c
index 90c57c72..e3b487be 100644
--- a/gi/pygi-boxed.c
+++ b/gi/pygi-boxed.c
@@ -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)
diff --git a/tests/test_gobject.py b/tests/test_gobject.py
index 9b4656b4..7816510c 100644
--- a/tests/test_gobject.py
+++ b/tests/test_gobject.py
@@ -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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]