From a66aa434f933526663d62d202f9bd7841d52449e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 16 Mar 2010 12:35:13 -0400 Subject: [PATCH] Don't crash in DND when the X server doesn't support SHAPE Reported in bug 612768 (cherry picked from commit 996541d096d4d59e9baa384e5d5359a10567433e) --- gdk/x11/gdkwindow-x11.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 19142584f8..58ff6a3011 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -4606,14 +4606,18 @@ _xwindow_get_shape (Display *xdisplay, gint rn, ord, i; shape = NULL; - + rn = 0; + xrl = XShapeGetRectangles (xdisplay, window, shape_type, &rn, &ord); - + + if (xrl == NULL) + return NULL; /* XShape not supported */ + if (rn == 0) return gdk_region_new (); /* Empty */ - + if (ord != YXBanded) { /* This really shouldn't happen with any xserver, as they @@ -4650,21 +4654,20 @@ _gdk_windowing_get_shape_for_mask (GdkBitmap *mask) display = gdk_drawable_get_display (GDK_DRAWABLE (mask)); window = XCreateSimpleWindow (GDK_DISPLAY_XDISPLAY (display), - GDK_SCREEN_XROOTWIN (gdk_display_get_default_screen (display)), - -1, -1, 1, 1, 0, - 0, 0); + GDK_SCREEN_XROOTWIN (gdk_display_get_default_screen (display)), + -1, -1, 1, 1, 0, + 0, 0); XShapeCombineMask (GDK_DISPLAY_XDISPLAY (display), - window, - ShapeBounding, - 0, 0, - GDK_PIXMAP_XID (mask), - ShapeSet); - - region = _xwindow_get_shape (GDK_DISPLAY_XDISPLAY (display), - window, ShapeBounding); + window, + ShapeBounding, + 0, 0, + GDK_PIXMAP_XID (mask), + ShapeSet); - XDestroyWindow (GDK_DISPLAY_XDISPLAY (display), - window); + region = _xwindow_get_shape (GDK_DISPLAY_XDISPLAY (display), + window, ShapeBounding); + + XDestroyWindow (GDK_DISPLAY_XDISPLAY (display), window); return region; }