[pygobject/gi-boxed-remove-del: 3/3] Remove GObject.Value.__del__



commit 49ecd45e8edfd05ecf6c7e3e71c8f0d81b522357
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         | 5 ++++-
 tests/test_gobject.py   | 6 ------
 3 files changed, 4 insertions(+), 11 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..c5f0ed9c 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);
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]