winex11 - Fix X11DRV_DIB_GetImageBits() when target bitmaps are larger than fetched - refix 2

Peter Dons Tychsen donpedro at tdcadsl.dk
Tue Jul 3 19:13:44 CDT 2007


Hello again,

Here is yet another revised version of my patch, after feedback from
Julliard. I now got rid of the line wrapping in the patch.

Bug: XShmGetImage() uses the bmpImage variable to calculate how much
data is to be fetched from the pixmap. If the bmpImage is larger than
the available data in capture, then XShmGetImage() call will therefore
fail, and will spam the user with X errors in the console (not Wine
output). Therefore this patch checks too see if this is the case. If it
is, the function falls back on XGetSubImage() to do the work.

Why XGetSubImage() is not always used i do not know, but presumably it
is because XShmGetImage() is faster. Anyway, now it works for all cases.

This patch fixes apps which like to use large bitmaps for small
captures. Not a common thing, but it happens (and is valid).
Usually the app will crash without this fix.

/pedro, DK


>From 370aa2f1ee383f3340c875a7ee8ab92c8f8a11a8 Mon Sep 17 00:00:00 2001
From: Peter Dons Tychsen <donpedro at dhcppc2.(none)>
Date: Tue, 26 Jun 2007 15:39:30 +0200
Subject: [PATCH] Fixed X11DRV_DIB_GetImageBits() to be able to handle bitmap
targets which are larger than the area being fetched when XShmGetImage()
is being used
---
 dlls/winex11.drv/dib.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/dlls/winex11.drv/dib.c b/dlls/winex11.drv/dib.c
index c921034..78ae6b2 100644
--- a/dlls/winex11.drv/dib.c
+++ b/dlls/winex11.drv/dib.c
@@ -3618,7 +3618,11 @@ static int X11DRV_DIB_GetImageBits( const X11DRV_DIB_IMAGEBITS_DESCR *descr )
     }
 
 #ifdef HAVE_LIBXXSHM
-    if (descr->image && descr->useShm)
+
+    /* We must not call XShmGetImage() with a bitmap which is bigger than the avilable area.
+       If we do, XShmGetImage() will fail (X exception), as it checks for this internally. */
+    if((descr->image && descr->useShm) && (bmpImage->width <= (descr->width - descr->xSrc)) 
+      && (bmpImage->height <= (descr->height - descr->ySrc)))
     {
         int saveRed, saveGreen, saveBlue;
 
-- 
1.5.0.6





More information about the wine-patches mailing list