<div dir="ltr">The issue isn't "there's already a role". The issue is that we don't allow two xdg_surface proxies for the same surface (a currently-undocumented but sane limitation). For pretty much any other surface role, allowing the surface to re-gain its role is a feature, not a bug.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 5, 2015 at 1:46 PM, Bill Spitzak <span dir="ltr"><<a href="mailto:spitzak@gmail.com" target="_blank">spitzak@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">How about a wrapper function around weston_surface_set_role that always fails if there is a non-zero role, and then call that? You can then gradually transition all the other calls to this new one, and if they are all changed then remove the old function.<div class="HOEnZb"><div class="h5"><br>
<br>
On 02/05/2015 05:21 AM, Jonas Ådahl wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If a client calls xdg_shell.get_xdg_surface on a surface that is already<br>
an xdg_surface wold, prior to this patch, succeed, but cause weston to<br>
crash later when trying to configure. This patch instead sends a role<br>
error to the client complaining that it already is an xdg_surface.<br>
<br>
Note that .._set_role() only fails when changing roles, not when setting<br>
the same role twice.<br>
<br>
The same is done for xdg_popup.<br>
<br>
Signed-off-by: Jonas Ådahl <<a href="mailto:jadahl@gmail.com" target="_blank">jadahl@gmail.com</a>><br>
Reviewed-by: Daniel Stone <<a href="mailto:daniels@collabora.com" target="_blank">daniels@collabora.com</a>><br>
---<br>
<br>
Changed since v1:<br>
<br>
Put the assignments on their own lines.<br>
<br>
<br>
  desktop-shell/shell.c | 16 ++++++++++++++++<br>
  1 file changed, 16 insertions(+)<br>
<br>
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c<br>
index a7514f7..d4407d0 100644<br>
--- a/desktop-shell/shell.c<br>
+++ b/desktop-shell/shell.c<br>
@@ -3959,6 +3959,14 @@ xdg_get_xdg_surface(struct wl_client *client,<br>
        struct desktop_shell *shell = sc->shell;<br>
        struct shell_surface *shsurf;<br>
<br>
+       shsurf = get_shell_surface(surface);<br>
+       if (shsurf && shell_surface_is_xdg_surface(<u></u>shsurf)) {<br>
+               wl_resource_post_error(<u></u>resource, XDG_SHELL_ERROR_ROLE,<br>
+                                      "This wl_surface is already an "<br>
+                                      "xdg_surface");<br>
+               return;<br>
+       }<br>
+<br>
        if (weston_surface_set_role(<u></u>surface, "xdg_surface",<br>
                                    resource, XDG_SHELL_ERROR_ROLE) < 0)<br>
                return;<br>
@@ -4052,6 +4060,14 @@ xdg_get_xdg_popup(struct wl_client *client,<br>
        struct weston_surface *parent;<br>
        struct shell_seat *seat;<br>
<br>
+       shsurf = get_shell_surface(surface);<br>
+       if (shsurf && shell_surface_is_xdg_popup(<u></u>shsurf)) {<br>
+               wl_resource_post_error(<u></u>resource, XDG_SHELL_ERROR_ROLE,<br>
+                                      "This wl_surface is already an "<br>
+                                      "xdg_popup");<br>
+               return;<br>
+       }<br>
+<br>
        if (weston_surface_set_role(<u></u>surface, "xdg_popup",<br>
                                    resource, XDG_SHELL_ERROR_ROLE) < 0)<br>
                return;<br>
<br>
</blockquote></div></div><div class="HOEnZb"><div class="h5">
______________________________<u></u>_________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org" target="_blank">wayland-devel@lists.<u></u>freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/<u></u>mailman/listinfo/wayland-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">  Jasper<br></div>
</div>