[pygobject/pygobject-2-28] [gi] remove unref for closures since they are floating objects that get sunk
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/pygobject-2-28] [gi] remove unref for closures since they are floating objects that get sunk
- Date: Thu, 3 Mar 2011 23:47:18 +0000 (UTC)
commit c2cfdfa6c08b9da6bff9fc9d479e441a83cbf60a
Author: John (J5) Palmieri <johnp redhat com>
Date: Tue Mar 1 12:19:28 2011 -0500
[gi] remove unref for closures since they are floating objects that get sunk
* right now we trust that the containers we send the closures into will sink
them
* we should research this a bit more to see if there is a better way to handle
floating closures once we are free to break static binding ABI
* for now this is the least invasive of all the options
* don't assert on transfer != GI_TRANSFER_NONE since the behavior for
closures is always the same (and should actually be GI_TRANSFER_FULL)
gi/pygi-argument.c | 6 ------
tests/test_overrides.py | 8 ++++++++
2 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index bbbad00..1b31387 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -1072,8 +1072,6 @@ array_success:
} else if (g_type_is_a (type, G_TYPE_CLOSURE)) {
GClosure *closure;
- g_warn_if_fail (transfer == GI_TRANSFER_NOTHING);
-
closure = pyg_closure_new (object, NULL, NULL);
if (closure == NULL) {
PyErr_SetString (PyExc_RuntimeError, "PyObject conversion to GClosure failed");
@@ -1973,10 +1971,6 @@ _pygi_argument_release (GIArgument *arg,
|| (direction == GI_DIRECTION_OUT && transfer != GI_TRANSFER_NOTHING)) {
g_slice_free (GValue, value);
}
- } else if (g_type_is_a (type, G_TYPE_CLOSURE)) {
- if (direction == GI_DIRECTION_IN && transfer == GI_TRANSFER_NOTHING) {
- g_closure_unref (arg->v_pointer);
- }
} else if (g_struct_info_is_foreign ( (GIStructInfo*) info)) {
if (direction == GI_DIRECTION_OUT && transfer == GI_TRANSFER_EVERYTHING) {
pygi_struct_foreign_release (info, arg->v_pointer);
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index e2333b1..aaf593e 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -1446,3 +1446,11 @@ class TestGio(unittest.TestCase):
self.assertEqual(len(empty), 0)
self.assertEqual(bool(empty), True)
self.assertEqual(empty.keys(), [])
+
+ def test_closures(self):
+ # make sure this doesn't crash
+ def fake_cb(*args):
+ pass
+
+ ag = Gtk.AccelGroup()
+ ag.connect(Gdk.KEY_l, Gdk.ModifierType.CONTROL_MASK, 0, fake_cb)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]