From: Po Lu Date: Sun, 20 Mar 2022 03:23:11 +0000 (+0800) Subject: Fix crash on some compositing managers X-Git-Tag: emacs-29.0.90~1931^2~1036 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=629ac0803f29dcc9b5be5f704c0892b121f6adf5;p=emacs.git Fix crash on some compositing managers * src/xterm.c (x_dnd_get_target_window): Catch errors around CompositeReleaseOverlayWindow. --- diff --git a/src/xterm.c b/src/xterm.c index 3e888407b3b..3e7b51e4db3 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -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 (); } }