[PATCH v2] xwayland: Fix infinite loop on quick movement through menus

Kristian Hoegsberg hoegsberg at gmail.com
Wed Apr 25 07:34:14 PDT 2012


On Wed, Apr 25, 2012 at 03:06:57PM +0200, Tomasz Borowik wrote:
> From 3abf39489deb3eb048174630dc7d41908674408b Mon Sep 17 00:00:00 2001
> From: timon37 <timon37 at lavabit.com>
> Date: Wed, 25 Apr 2012 13:28:35 +0200
> Subject: [PATCH] Fix infinite loop in xwl_screen_post_damage
> 
> Happens when first two windows are damaged, then later one is damaged and
> the other is unrealized. It makes the damaged windows next point to itself.

Ah, yes, good catch.

The way we should fix this is that we just

    xorg_list_init(&xwl_window->damage_link);

in xwl_screen_post_damage() as we iterate list.  That way we can
unconditional call xorg_list_del(&xwl_window->link_damage); as we do
now.  If it's on the list, we take it out, if it's not on the list,
it's a no-op.

Kristian


> Triggers most often on menus or tooltips.
> ---
>  hw/xfree86/xwayland/xwayland-window.c |   11 +++++++++--
>  1 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/xfree86/xwayland/xwayland-window.c b/hw/xfree86/xwayland/xwayland-window.c
> index e58350f..bc444af 100644
> --- a/hw/xfree86/xwayland/xwayland-window.c
> +++ b/hw/xfree86/xwayland/xwayland-window.c
> @@ -218,7 +218,7 @@ xwl_unrealize_window(WindowPtr window)
>  {
>      ScreenPtr screen = window->drawable.pScreen;
>      struct xwl_screen *xwl_screen;
> -    struct xwl_window *xwl_window;
> +    struct xwl_window *xwl_window, *iter, *tmp;
>      struct xwl_input_device *xwl_input_device;
>      Bool ret;
>  
> @@ -248,7 +248,14 @@ xwl_unrealize_window(WindowPtr window)
>  	wl_buffer_destroy(xwl_window->buffer);
>      wl_surface_destroy(xwl_window->surface);
>      xorg_list_del(&xwl_window->link);
> -    xorg_list_del(&xwl_window->link_damage);
> +    
> +    xorg_list_for_each_entry_safe(iter, tmp,
> +			     &xwl_screen->damage_window_list, link_damage) {
> +	if (iter == xwl_window) {
> +	    xorg_list_del(&xwl_window->link_damage);
> +	    break;
> +	}
> +    }
>      DamageUnregister(&window->drawable, xwl_window->damage);
>      DamageDestroy(xwl_window->damage);
>      free(xwl_window);
> -- 
> 1.7.8.5
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list