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.
This commit is contained in:
		
							parent
							
								
									b614ded3fc
								
							
						
					
					
						commit
						34303e1b47
					
				|  | @ -667,8 +667,14 @@ bool wlr_surface_set_role(struct wlr_surface *surface, | ||||||
| 		} | 		} | ||||||
| 		return false; | 		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 = role; | ||||||
| 	surface->role_data = role_data; | 	surface->role_data = role_data; | ||||||
| 	return true; | 	return true; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue