aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Anderson <scott@anderso.nz>2020-03-22 00:55:54 +1300
committerSimon Ser <contact@emersion.fr>2020-03-21 13:58:27 +0100
commit34303e1b47defc7aca518983ac3aaea6c881d112 (patch)
tree3785e50c4dbade839cf31c59b6bd49241d7adc08
parentb614ded3fcb022c4567bbee932a6df3e83acaff6 (diff)
wlr_surface: Post error if multiple role objects created
This fixes an assertion failure if a client tries to do this, e.g. by creating multiple toplevel objects for the same surface. If the same role data is set multiple times, this does not cause an error, which is how cursors use this interface.
-rw-r--r--types/wlr_surface.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/types/wlr_surface.c b/types/wlr_surface.c
index 244a2cad..0b2e8c09 100644
--- a/types/wlr_surface.c
+++ b/types/wlr_surface.c
@@ -667,8 +667,14 @@ bool wlr_surface_set_role(struct wlr_surface *surface,
}
return false;
}
+ if (surface->role_data != NULL && surface->role_data != role_data) {
+ wl_resource_post_error(error_resource, error_code,
+ "Cannot reassign role %s to wl_surface@%d,"
+ "role object still exists", role->name,
+ wl_resource_get_id(surface->resource));
+ return false;
+ }
- assert(surface->role_data == NULL);
surface->role = role;
surface->role_data = role_data;
return true;