[PATCH weston] xwayland: set surface_id to 0 when client resource is found

Jason Ekstrand jason at jlekstrand.net
Thu Jul 24 13:23:57 PDT 2014


Thanks.  I just pushed this (with a small fix to change the variable name
from "surface" to "id").
--Jason Ekstrand


On Sun, Jul 20, 2014 at 1:10 AM, Boyan Ding <stu_dby at 126.com> wrote:

> Only when reading through mails today did I find I had duplicated
> efforts [1], sorry.
>
> This patch is
> Reviewed-by: Boyan Ding <stu_dby at 126.com>
>
> [1]
> http://lists.freedesktop.org/archives/wayland-devel/2014-July/015943.html
>
> On Wed, 2014-07-02 at 15:00 -0700, Tyler Veness wrote:
> > When Xwayland requests that a wl_surface be created and the X event is
> > handled before the wayland requests, a surface ID is stored to
> > window->surface_id and the window is added to the unpaired window list.
> When
> > weston_wm_create_surface is called, the window is removed from the list
> and
> > window->surface_id is set to zero. If window->surface_id is not zero when
> > weston_wm_window_destroy is called, the window is assumed to be in the
> > unpaired window list and wl_list_remove is called. If
> > weston_wm_window_handle_surface_id is called and the surface has already
> > been created, the window is not added to the unpaired window list, but
> > window->surface_id isn't set to zero. When the window is destroyed,
> removing
> > the window from the list is attempted anyway and a crash occurs.
> >
> > This patch stores the surface ID in a temporary variable and only
> assigns it
> > to window->surface_id when the window is added to the unpaired window
> list.
> > Otherwise window->surface_id is set to zero to maintain its use as a flag
> > variable.
> >
> > Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=80273
> > Signed-off-by: Tyler Veness <calcmogul at gmail.com>
> > ---
> >  xwayland/window-manager.c | 13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
> > index 2fb65b1..4c98baf 100644
> > --- a/xwayland/window-manager.c
> > +++ b/xwayland/window-manager.c
> > @@ -1374,14 +1374,17 @@ weston_wm_window_handle_surface_id(struct
> weston_wm_window *window,
> >        * hasn't been created yet.  In that case put the window on
> >        * the unpaired window list and continue when the surface gets
> >        * created. */
> > -     window->surface_id = client_message->data.data32[0];
> > -     resource = wl_client_get_object(wm->server->client,
> > -                                     window->surface_id);
> > -     if (resource)
> > +     uint32_t surface = client_message->data.data32[0];
> > +     resource = wl_client_get_object(wm->server->client, surface);
> > +     if (resource) {
> > +             window->surface_id = 0;
> >               xserver_map_shell_surface(window,
> >
> wl_resource_get_user_data(resource));
> > -     else
> > +     }
> > +     else {
> > +             window->surface_id = surface;
> >               wl_list_insert(&wm->unpaired_window_list, &window->link);
> > +     }
> >  }
> >
> >  static void
>
>
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20140724/7dc231bf/attachment.html>


More information about the wayland-devel mailing list