Improve handling of errors when calling CompositeNameWindowPixmap
To guard against CompositeNameWindowPixmap failing, just use an error trap. Previous code used: GrabServer/GetWindowAttributes/CompositeNameWindowPixmap/UngrabServer To prevent BadMatch errors from !viewable, but didn't check the return value of GetWindowAttributes and didn't check if an error occured during the error trap. This way is more correct and more efficient. http://bugzilla.gnome.org/show_bug.cgi?id=580023
This commit is contained in:
parent
626912a9a4
commit
63b1d6642c
@ -1474,23 +1474,22 @@ repair_win (MutterWindow *cw)
|
|||||||
if (priv->back_pixmap == None)
|
if (priv->back_pixmap == None)
|
||||||
{
|
{
|
||||||
gint pxm_width, pxm_height;
|
gint pxm_width, pxm_height;
|
||||||
XWindowAttributes attr;
|
|
||||||
|
|
||||||
meta_error_trap_push (display);
|
meta_error_trap_push (display);
|
||||||
|
|
||||||
XGrabServer (xdisplay);
|
priv->back_pixmap = XCompositeNameWindowPixmap (xdisplay, xwindow);
|
||||||
|
|
||||||
XGetWindowAttributes (xdisplay, xwindow, &attr);
|
if (meta_error_trap_pop_with_return (display, FALSE) != Success)
|
||||||
|
{
|
||||||
if (attr.map_state == IsViewable)
|
/* Probably a BadMatch if the window isn't viewable; we could
|
||||||
priv->back_pixmap = XCompositeNameWindowPixmap (xdisplay, xwindow);
|
* GrabServer/GetWindowAttributes/NameWindowPixmap/UngrabServer/Sync
|
||||||
else
|
* to avoid this, but there's no reason to take two round trips
|
||||||
{
|
* when one will do. (We need that Sync if we want to handle failures
|
||||||
priv->back_pixmap = None;
|
* for any reason other than !viewable. That's unlikely, but maybe
|
||||||
}
|
* we'll BadAlloc or something.)
|
||||||
|
*/
|
||||||
XUngrabServer (xdisplay);
|
priv->back_pixmap = None;
|
||||||
meta_error_trap_pop (display, FALSE);
|
}
|
||||||
|
|
||||||
if (priv->back_pixmap == None)
|
if (priv->back_pixmap == None)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user