diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 3b82590e3a..39862906ca 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -2721,6 +2721,7 @@ _gdk_x11_display_error_event (GdkDisplay *display, { ignore = TRUE; trap->error_code = error->error_code; + break; /* only innermost trap gets the error code */ } } diff --git a/tests/testerrors.c b/tests/testerrors.c index b8d1a8a812..d371f1b790 100755 --- a/tests/testerrors.c +++ b/tests/testerrors.c @@ -56,13 +56,22 @@ test_error_trapping (GdkDisplay *gdk_display) XSync (d, TRUE); - /* verify that we can catch with nested traps */ + /* verify that we can catch with nested traps; inner-most + * active trap gets the error */ gdk_error_trap_push (); gdk_error_trap_push (); XSetCloseDownMode (d, 12345); error = gdk_error_trap_pop (); g_assert (error == BadValue); error = gdk_error_trap_pop (); + g_assert (error == Success); + + gdk_error_trap_push (); + XSetCloseDownMode (d, 12345); + gdk_error_trap_push (); + error = gdk_error_trap_pop (); + g_assert (error == Success); + error = gdk_error_trap_pop (); g_assert (error == BadValue); /* try nested, without sync */