]> Pileus Git - ~andy/gtk/commitdiff
Only store error codes in inner-most X error trap
authorOwen W. Taylor <otaylor@fishsoup.net>
Mon, 20 Sep 2010 20:12:11 +0000 (16:12 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Mon, 20 Sep 2010 20:35:41 +0000 (16:35 -0400)
When an error occurs with nested traps in place, only the innermost
trap should have the error code stored in it; outer traps are
shielded by the inner trap.

https://bugzilla.gnome.org/show_bug.cgi?id=629608

gdk/x11/gdkdisplay-x11.c
tests/testerrors.c

index 3b82590e3afb8ff5c85703cbd8b1d7a2d623f776..39862906caf221f95c941250e8d21a3656bf10d0 100644 (file)
@@ -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 */
         }
     }
 
index b8d1a8a812653fd365c31cc50363536143b563e3..d371f1b790b8421604eb685f82e4f4234ef3b422 100755 (executable)
@@ -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 */