[PATCH] xnest: Ignore GetImage() error in xnestGetImage()
Daniel Stone
daniel at fooishbar.org
Mon Aug 12 13:00:45 PDT 2013
Hi,
This will be a bit too broad, ignoring errors generated before the
XGetImage but only posted then. To avoid that, you need to call
XSync(dpy, False) before changing the error handler.
Cheers,
Daniel
On 12 August 2013 17:23, Egbert Eich <eich at freedesktop.org> wrote:
> From: Radek Doulik <rodo at novell.com>
>
> When an Xnest instance is not viable it will crash when a client in that
> instance calls GetImage. This is because the Xnest server will itself
> receives a BadMatch error.
> This patch ignores the error. The application which has requested the
> image will receive garbage - this however is fully legal according
> to the specs as obscured areas will always contain garbage if there
> isn't some sort of backing store as discussed in
> https://bugs.freedesktop.org/show_bug.cgi?id=9488
> The applied patch is a version from Dadek Doulik.
>
> Signed-off-by: Egbert Eich <eich at freedesktop.org>
> ---
> hw/xnest/GCOps.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c
> index e26a136..1c2773a 100644
> --- a/hw/xnest/GCOps.c
> +++ b/hw/xnest/GCOps.c
> @@ -94,15 +94,27 @@ xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
> }
> }
>
> +static int
> +xnestIgnoreErrorHandler (Display *display,
> + XErrorEvent *event)
> +{
> + return False; /* return value is ignored */
> +}
> +
> void
> xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
> unsigned int format, unsigned long planeMask, char *pImage)
> {
> XImage *ximage;
> int length;
> + int (*old_handler)(Display*, XErrorEvent*);
> +
> + /* we may get BadMatch error when xnest window is minimized */
> + old_handler = XSetErrorHandler (xnestIgnoreErrorHandler);
>
> ximage = XGetImage(xnestDisplay, xnestDrawable(pDrawable),
> x, y, w, h, planeMask, format);
> + XSetErrorHandler(old_handler);
>
> if (ximage) {
> length = ximage->bytes_per_line * ximage->height;
> --
> 1.8.1.4
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
More information about the xorg-devel
mailing list