diff options
author | Havoc Pennington <hp@pobox.com> | 2010-09-18 23:03:31 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2010-09-18 23:03:31 -0400 |
commit | e32ab82069cb99b8a7e649b9d6e09dd2c66904ec (patch) | |
tree | fc33e7cef4bc170fb9bb9f1d688883dc3b29f403 /gdk | |
parent | c7d73ee5875786f88ab72ed94072d25c207bcf94 (diff) | |
download | gtk+-e32ab82069cb99b8a7e649b9d6e09dd2c66904ec.tar.gz |
Improve tests for X error traps, fix two bugs
* don't lose track of previous X error handler
if nested traps are pushed
* free any remaining traps when display
is finalized
Test will fail unless bug 630032 is closed so
gdk_display_close() works.
https://bugzilla.gnome.org/show_bug.cgi?id=630033
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/x11/gdkdisplay-x11.c | 15 | ||||
-rw-r--r-- | gdk/x11/gdkmain-x11.c | 13 |
2 files changed, 25 insertions, 3 deletions
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index ea4e9914dc..3b82590e3a 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -1911,6 +1911,21 @@ gdk_display_x11_finalize (GObject *object) XCloseDisplay (display_x11->xdisplay); + /* error traps */ + while (display_x11->error_traps != NULL) + { + GdkErrorTrap *trap = display_x11->error_traps->data; + + display_x11->error_traps = + g_slist_delete_link (display_x11->error_traps, + display_x11->error_traps); + + if (trap->end_sequence == 0) + g_warning ("Display finalized with an unpopped error trap"); + + g_slice_free (GdkErrorTrap, trap); + } + G_OBJECT_CLASS (_gdk_display_x11_parent_class)->finalize (object); } diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index 996715c75f..ca20f97304 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -62,7 +62,8 @@ struct _GdkPredicate }; /* non-GDK previous error handler */ -static int (*_gdk_old_error_handler) (Display *, XErrorEvent *); +typedef int (*GdkXErrorHandler) (Display *, XErrorEvent *); +static GdkXErrorHandler _gdk_old_error_handler; /* number of times we've pushed the GDK error handler */ static int _gdk_error_handler_push_count = 0; @@ -386,13 +387,19 @@ gdk_x_error (Display *xdisplay, void _gdk_x11_error_handler_push (void) { - _gdk_old_error_handler = XSetErrorHandler (gdk_x_error); + GdkXErrorHandler previous; + + previous = XSetErrorHandler (gdk_x_error); if (_gdk_error_handler_push_count > 0) { - if (_gdk_old_error_handler != gdk_x_error) + if (previous != gdk_x_error) g_warning ("XSetErrorHandler() called with a GDK error trap pushed. Don't do that."); } + else + { + _gdk_old_error_handler = previous; + } _gdk_error_handler_push_count += 1; } |