summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2021-04-27 18:32:06 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2021-04-27 18:35:49 +0200
commiteb5aefa615e85e023920c366225a67b602a812db (patch)
tree6f514e4a708f4e7adc1ee202067fac3d835769fa
parent91b8381d37614b251a3617ae4750d036fa688d55 (diff)
downloadpygobject-eb5aefa615e85e023920c366225a67b602a812db.tar.gz
Expose GObject.Object.run_dispose()
Up until now this raised an exception "This method is currently unsupported.". With Gtk.Widget.destroy() gone in gtk4 and that method often being used to remove references to other objects and breaking cycles this is the next best thing on a lower level and should make porting a bit easier. Fixes #470
-rw-r--r--gi/overrides/GObject.py1
-rw-r--r--tests/test_gobject.py19
2 files changed, 19 insertions, 1 deletions
diff --git a/gi/overrides/GObject.py b/gi/overrides/GObject.py
index 95a3c1f3..823c0b04 100644
--- a/gi/overrides/GObject.py
+++ b/gi/overrides/GObject.py
@@ -520,7 +520,6 @@ class Object(GObjectModule.Object):
interface_install_property = _unsupported_method
interface_list_properties = _unsupported_method
notify_by_pspec = _unsupported_method
- run_dispose = _unsupported_method
watch_closure = _unsupported_method
# Make all reference management methods private but still accessible.
diff --git a/tests/test_gobject.py b/tests/test_gobject.py
index f5a65bba..fbc3bb79 100644
--- a/tests/test_gobject.py
+++ b/tests/test_gobject.py
@@ -67,6 +67,25 @@ def test_gobject_weak_ref():
class TestGObjectAPI(unittest.TestCase):
+ def test_run_dispose(self):
+ class TestObject(GObject.GObject):
+ int_prop = GObject.Property(default=0, type=int)
+
+ obj = TestObject()
+ called = []
+
+ def on_notify(*args):
+ called.append(args)
+
+ obj.connect('notify::int-prop', on_notify)
+ obj.notify("int-prop")
+ obj.notify("int-prop")
+ # after this everything should be disconnected
+ obj.run_dispose()
+ obj.notify("int-prop")
+ obj.notify("int-prop")
+ assert len(called) == 2
+
def test_call_method_uninitialized_instance(self):
obj = GObject.Object.__new__(GObject.Object)
with self.assertRaisesRegex(RuntimeError, '.*is not initialized'):