On Wed, Sep 11, 2013 at 08:54:13PM +0200, Giulio Camuffo wrote: > with the surface ref-count feature a surface may live on after its > resource was destroyed. set it to NULL in that case, so that code > like find_resource_for_surface() in input.c will act accordingly. > --- > src/compositor.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/src/compositor.c b/src/compositor.c > index 88df279..a79f911 100644 > --- a/src/compositor.c > +++ b/src/compositor.c > @@ -1071,6 +1071,9 @@ destroy_surface(struct wl_resource *resource) > struct weston_surface *surface = wl_resource_get_user_data(resource); > > weston_surface_destroy(surface); > + /* the surface may live so make sure nothing thinks > + it still has a resourc*e */ > + surface->resource = NULL;
This avoids the warning, but we might access freed memory here. And if we did something like checking for ref_count > 1 before calling weston_surface_destroy() and then setting resource to NULL after if the ref_count was > 1, we'll run into a problem when we later destroy the surface for real. We'll end up in weston_pointer_set_focus(), called from weston_surface_unmap() and there we'll send out the leave event with the NULL resource. So I think the right course of action is to not send out the leave event if pointer->focus is NULL. We discussed this back when we had the leave event warning and I wasn't too happy about doing that, but in the end I don't see a way around this. Kristian > } > > static void > -- > 1.8.4 > > _______________________________________________ > wayland-devel mailing list > wayland-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/wayland-devel _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel