From df21dbbc84fa319af2a0f0664de436ca30df616e Mon Sep 17 00:00:00 2001 From: Simon Feltman Date: Thu, 16 Jan 2014 16:33:41 -0800 Subject: tests: Add skipped test for GLib.Source inheritance problems Add test showing memory problems with sub-classes of GLib.Source. https://bugzilla.gnome.org/show_bug.cgi?id=722387 --- tests/test_source.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/test_source.py b/tests/test_source.py index 6f69927b..e0910f9d 100644 --- a/tests/test_source.py +++ b/tests/test_source.py @@ -220,6 +220,51 @@ class TestSource(unittest.TestCase): del source self.assertTrue(self.finalized) + @unittest.skip('https://bugzilla.gnome.org/show_bug.cgi?id=722387') + def test_python_unref_with_active_source(self): + # Tests a Python derived Source which is free'd in the context of + # Python, but remains active in the MainContext (via source.attach()) + self.dispatched = False + self.finalized = False + + class S(GLib.Source): + def prepare(s): + return (True, 1) + + def check(s): + pass + + def dispatch(s, callback, args): + self.dispatched = True + return False + + def finalize(s): + self.finalized = True + + source = S() + id = source.attach() + self.assertFalse(self.finalized) + self.assertFalse(source.is_destroyed()) + + # Delete the source from Python but should still remain + # active in the main context. + del source + + context = GLib.MainContext.default() + while context.iteration(may_block=False): + pass + + self.assertTrue(self.dispatched) + self.assertFalse(self.finalized) + + source = context.find_source_by_id(id) + source.destroy() # Remove from main context. + self.assertTrue(source.is_destroyed()) + + # Source should be finalized called after del + del source + self.assertTrue(self.finalized) + def test_extra_init_args(self): class SourceWithInitArgs(GLib.Source): def __init__(self, arg, kwarg=None): -- cgit v1.2.1