diff options
author | John Ehresman <jpe@wingware.com> | 2006-01-20 21:27:27 +0000 |
---|---|---|
committer | John Ehresman <jpe@src.gnome.org> | 2006-01-20 21:27:27 +0000 |
commit | 53df8ba50db2bb435762037c9c8544178696b274 (patch) | |
tree | da7d6b9a1adfc48069fab25a40f927ba443e03ea /tests/test_gdk.py | |
parent | ec718aaf077d2fabe791cb6a00acfd12454ce4cc (diff) | |
download | pygtk-53df8ba50db2bb435762037c9c8544178696b274.tar.gz |
Bump ref count on x11 so destroy() works as expected
2006-01-20 John Ehresman <jpe@wingware.com>
* gtk/gdk.override (_wrap_gdk_window_new): Bump ref count
on x11 so destroy() works as expected
* tests/test_gdk.py: test for the above
Diffstat (limited to 'tests/test_gdk.py')
-rw-r--r-- | tests/test_gdk.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_gdk.py b/tests/test_gdk.py index 7bbaf9ae..588b296e 100644 --- a/tests/test_gdk.py +++ b/tests/test_gdk.py @@ -1,7 +1,14 @@ import unittest +import gc from common import gtk +class CallOnDel: + def __init__(self, callback): + self.callback = callback + def __del__(self): + self.callback() + class GdkTest(unittest.TestCase): def testBitmapCreateFromData(self): gtk.gdk.bitmap_create_from_data(None, '\x00', 1, 1) @@ -10,3 +17,20 @@ class GdkTest(unittest.TestCase): black = gtk.gdk.color_parse('black') gtk.gdk.pixmap_create_from_data(None, '\x00', 1, 1, 1, black, black) + + def testWindow(self): + common = {'finalized': False} + def on_finalize(): + common['finalized'] = True + w = gtk.gdk.Window(None, 200, 200, gtk.gdk.WINDOW_TEMP, 0, 0) + w.set_data('foo', CallOnDel(on_finalize)) + w.destroy() + while gtk.events_pending(): + gtk.main_iteration(block=False) + del w + + # Note that this depends on the mainloop processing an X event so + # if might fail if the timing is off + while gc.collect(): + pass + assert common['finalized'] |