]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix crash on some compositing managers
authorPo Lu <luangruo@yahoo.com>
Sun, 20 Mar 2022 03:23:11 +0000 (11:23 +0800)
committerPo Lu <luangruo@yahoo.com>
Sun, 20 Mar 2022 03:23:11 +0000 (11:23 +0800)
* src/xterm.c (x_dnd_get_target_window): Catch errors around
CompositeReleaseOverlayWindow.

src/xterm.c

index 3e888407b3b9552df0bb10c92fade21160eccb1b..3e7b51e4db3f6c7cfb5b6472b95343f02e956c10 100644 (file)
@@ -911,27 +911,34 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo,
       if (XGetSelectionOwner (dpyinfo->display,
                              dpyinfo->Xatom_NET_WM_CM_Sn) != None)
        {
+         x_catch_errors (dpyinfo->display);
          overlay_window = XCompositeGetOverlayWindow (dpyinfo->display,
                                                       dpyinfo->root_window);
          XCompositeReleaseOverlayWindow (dpyinfo->display,
                                          dpyinfo->root_window);
-         XGetWindowAttributes (dpyinfo->display, overlay_window, &attrs);
-
-         if (attrs.map_state == IsViewable)
+         if (!x_had_errors_p (dpyinfo->display))
            {
-             proxy = x_dnd_get_window_proxy (dpyinfo, overlay_window);
+             XGetWindowAttributes (dpyinfo->display, overlay_window, &attrs);
 
-             if (proxy != None)
+             if (attrs.map_state == IsViewable)
                {
-                 proto = x_dnd_get_window_proto (dpyinfo, proxy);
+                 proxy = x_dnd_get_window_proxy (dpyinfo, overlay_window);
 
-                 if (proto != -1)
+                 if (proxy != None)
                    {
-                     *proto_out = proto;
-                     return proxy;
+                     proto = x_dnd_get_window_proto (dpyinfo, proxy);
+
+                     if (proto != -1)
+                       {
+                         *proto_out = proto;
+                         x_uncatch_errors_after_check ();
+
+                         return proxy;
+                       }
                    }
                }
            }
+         x_uncatch_errors_after_check ();
        }
     }