]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't sync for errors setting up DND targets and toplevels
authorPo Lu <luangruo@yahoo.com>
Sun, 10 Jul 2022 05:21:21 +0000 (13:21 +0800)
committerPo Lu <luangruo@yahoo.com>
Sun, 10 Jul 2022 05:22:58 +0000 (13:22 +0800)
* src/xterm.c (xm_setup_dnd_targets, x_dnd_free_toplevels)
(x_dnd_compute_toplevels): Avoid catching errors synchronously.

src/xterm.c

index 4e2d977e60f865f802d1a29f5f9a465e5a618358..e7e6ca7bf88c4eeb5bbab5d18a99c9a668771184 100644 (file)
@@ -2085,7 +2085,7 @@ xm_setup_dnd_targets (struct x_display_info *dpyinfo,
                           &actual_type, &actual_format, &nitems,
                           &bytes_remaining, &tmp_data) == Success;
   had_errors = x_had_errors_p (dpyinfo->display);
-  x_uncatch_errors ();
+  x_uncatch_errors_after_check ();
 
   /* The drag window is probably invalid, so remove our record of
      it.  */
@@ -2798,6 +2798,7 @@ x_dnd_free_toplevels (bool display_alive)
   unsigned long *prev_masks;
   specpdl_ref count;
   Display *dpy;
+  struct x_display_info *dpyinfo;
 
   if (!x_dnd_toplevels)
     /* Probably called inside an IO error handler.  */
@@ -2865,17 +2866,22 @@ x_dnd_free_toplevels (bool display_alive)
 
   if (display_alive)
     {
-      x_catch_errors (dpy);
+      dpyinfo = x_display_info_for_display (dpy);
 
-      for (i = 0; i < n_windows; ++i)
+      if (n_windows)
        {
-         XSelectInput (dpy, destroy_windows[i], prev_masks[i]);
+         x_ignore_errors_for_next_request (dpyinfo);
+
+         for (i = 0; i < n_windows; ++i)
+           {
+             XSelectInput (dpy, destroy_windows[i], prev_masks[i]);
 #ifdef HAVE_XSHAPE
-         XShapeSelectInput (dpy, destroy_windows[i], None);
+             XShapeSelectInput (dpy, destroy_windows[i], None);
 #endif
-       }
+           }
 
-      x_uncatch_errors ();
+         x_stop_ignoring_errors (dpyinfo);
+       }
     }
 
   unbind_to (count, Qnil);
@@ -3389,12 +3395,12 @@ x_dnd_compute_toplevels (struct x_display_info *dpyinfo)
            }
 #endif
 
-         x_catch_errors (dpyinfo->display);
+         x_ignore_errors_for_next_request (dpyinfo);
          XSelectInput (dpyinfo->display, toplevels[i],
                        (attrs.your_event_mask
                         | StructureNotifyMask
                         | PropertyChangeMask));
-         x_uncatch_errors ();
+         x_stop_ignoring_errors (dpyinfo);
 
          x_dnd_toplevels = tem;
        }