wayland: fix interface versioning

Add MIN(...) with the interface version actually implemented
to all resource constructor, so that we never risk seeing requests
we don't implement (and consequently segfault)

https://bugzilla.gnome.org/show_bug.cgi?id=707851
This commit is contained in:
Giovanni Campagna 2013-09-10 13:13:34 +02:00
parent 95a9655412
commit 73ee491281
3 changed files with 8 additions and 7 deletions

View File

@ -871,7 +871,7 @@ bind_shell (struct wl_client *client,
{ {
struct wl_resource *resource; struct wl_resource *resource;
resource = wl_resource_create (client, &wl_shell_interface, version, id); resource = wl_resource_create (client, &wl_shell_interface, MIN (1, version), id);
wl_resource_set_implementation (resource, &meta_wayland_shell_interface, data, NULL); wl_resource_set_implementation (resource, &meta_wayland_shell_interface, data, NULL);
} }
@ -973,7 +973,7 @@ bind_gtk_shell (struct wl_client *client,
{ {
struct wl_resource *resource; struct wl_resource *resource;
resource = wl_resource_create (client, &gtk_shell_interface, version, id); resource = wl_resource_create (client, &gtk_shell_interface, MIN (1, version), id);
wl_resource_set_implementation (resource, &meta_wayland_gtk_shell_interface, data, NULL); wl_resource_set_implementation (resource, &meta_wayland_gtk_shell_interface, data, NULL);
/* FIXME: ask the plugin */ /* FIXME: ask the plugin */

View File

@ -234,7 +234,7 @@ meta_wayland_compositor_create_surface (struct wl_client *wayland_client,
surface = meta_wayland_surface_create (compositor, surface = meta_wayland_surface_create (compositor,
wayland_client, wayland_client,
id, id,
wl_resource_get_version (wayland_compositor_resource)); MIN (3, wl_resource_get_version (wayland_compositor_resource)));
compositor->surfaces = g_list_prepend (compositor->surfaces, surface); compositor->surfaces = g_list_prepend (compositor->surfaces, surface);
} }
@ -297,7 +297,8 @@ meta_wayland_compositor_create_region (struct wl_client *wayland_client,
MetaWaylandRegion *region = g_slice_new0 (MetaWaylandRegion); MetaWaylandRegion *region = g_slice_new0 (MetaWaylandRegion);
region->resource = wl_resource_create (wayland_client, region->resource = wl_resource_create (wayland_client,
&wl_region_interface, 1, &wl_region_interface,
MIN (1, wl_resource_get_version (compositor_resource)),
id); id);
wl_resource_set_implementation (region->resource, wl_resource_set_implementation (region->resource,
&meta_wayland_region_interface, region, &meta_wayland_region_interface, region,
@ -335,7 +336,7 @@ bind_output (struct wl_client *client,
struct wl_resource *resource; struct wl_resource *resource;
guint mode_flags; guint mode_flags;
resource = wl_resource_create (client, &wl_output_interface, version, id); resource = wl_resource_create (client, &wl_output_interface, MIN (2, version), id);
wayland_output->resources = g_list_prepend (wayland_output->resources, resource); wayland_output->resources = g_list_prepend (wayland_output->resources, resource);
wl_resource_set_user_data (resource, wayland_output); wl_resource_set_user_data (resource, wayland_output);
@ -518,7 +519,7 @@ compositor_bind (struct wl_client *client,
MetaWaylandCompositor *compositor = data; MetaWaylandCompositor *compositor = data;
struct wl_resource *resource; struct wl_resource *resource;
resource = wl_resource_create (client, &wl_compositor_interface, version, id); resource = wl_resource_create (client, &wl_compositor_interface, MIN (3, version), id);
wl_resource_set_implementation (resource, &meta_wayland_compositor_interface, compositor, NULL); wl_resource_set_implementation (resource, &meta_wayland_compositor_interface, compositor, NULL);
} }

View File

@ -88,7 +88,7 @@ bind_xserver (struct wl_client *client,
return; return;
compositor->xserver_resource = compositor->xserver_resource =
wl_resource_create (client, &xserver_interface, version, id); wl_resource_create (client, &xserver_interface, MIN (1, version), id);
wl_resource_set_implementation (compositor->xserver_resource, wl_resource_set_implementation (compositor->xserver_resource,
&xserver_implementation, compositor, NULL); &xserver_implementation, compositor, NULL);