From: Derek Foreman <der...@osg.samsung.com> Add a helper function which determines whether or not an object is a zombie.
[daniels: Extracted from Derek's bespoke-zombie patch as an intermediate step.] Signed-off-by: Derek Foreman <der...@osg.samsung.com> Reviewed-by: Daniel Stone <dani...@collabora.com> Signed-off-by: Daniel Stone <dani...@collabora.com> --- src/connection.c | 10 +++++++++- src/wayland-client.c | 4 ++-- src/wayland-private.h | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/connection.c b/src/connection.c index e92de794..2e234ea5 100644 --- a/src/connection.c +++ b/src/connection.c @@ -831,6 +831,14 @@ wl_connection_demarshal(struct wl_connection *connection, return NULL; } +bool +wl_object_is_zombie(struct wl_map *map, uint32_t id) +{ + struct wl_object *object = wl_map_lookup(map, id); + + return (object == WL_ZOMBIE_OBJECT); +} + int wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects) { @@ -852,7 +860,7 @@ wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects) closure->args[i].o = NULL; object = wl_map_lookup(objects, id); - if (object == WL_ZOMBIE_OBJECT) { + if (wl_object_is_zombie(objects, id)) { /* references object we've already * destroyed client side */ object = NULL; diff --git a/src/wayland-client.c b/src/wayland-client.c index 795b4e9e..126dd908 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -837,7 +837,7 @@ display_handle_delete_id(void *data, struct wl_display *display, uint32_t id) if (!proxy) wl_log("error: received delete_id for unknown id (%u)\n", id); - if (proxy && proxy != WL_ZOMBIE_OBJECT) + if (proxy && !wl_object_is_zombie(&display->objects, id)) proxy->flags |= WL_PROXY_FLAG_ID_DELETED; else wl_map_remove(&display->objects, id); @@ -1253,7 +1253,7 @@ queue_event(struct wl_display *display, int len) return 0; proxy = wl_map_lookup(&display->objects, id); - if (!proxy || proxy == WL_ZOMBIE_OBJECT) { + if (!proxy || wl_object_is_zombie(&display->objects, id)) { wl_connection_consume(display->connection, size); return size; } diff --git a/src/wayland-private.h b/src/wayland-private.h index 93cec6be..c82b1f3e 100644 --- a/src/wayland-private.h +++ b/src/wayland-private.h @@ -190,6 +190,9 @@ wl_connection_demarshal(struct wl_connection *connection, struct wl_map *objects, const struct wl_message *message); +bool +wl_object_is_zombie(struct wl_map *map, uint32_t id); + int wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects); -- 2.14.3 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel