mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
client: Track the proxies attached to a queue
Maintain a list of all wl_proxy objects that are attached to a wl_event_queue. We will use this information in upcoming commits to warn about improper object destruction order that can lead to memory errors. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
This commit is contained in:
parent
ab526f8d7c
commit
674145dc3f
1 changed files with 22 additions and 0 deletions
|
|
@ -70,10 +70,12 @@ struct wl_proxy {
|
||||||
wl_dispatcher_func_t dispatcher;
|
wl_dispatcher_func_t dispatcher;
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
const char * const *tag;
|
const char * const *tag;
|
||||||
|
struct wl_list queue_link; /**< in struct wl_event_queue::proxy_list */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_event_queue {
|
struct wl_event_queue {
|
||||||
struct wl_list event_list;
|
struct wl_list event_list;
|
||||||
|
struct wl_list proxy_list; /**< struct wl_proxy::queue_link */
|
||||||
struct wl_display *display;
|
struct wl_display *display;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -221,6 +223,7 @@ static void
|
||||||
wl_event_queue_init(struct wl_event_queue *queue, struct wl_display *display)
|
wl_event_queue_init(struct wl_event_queue *queue, struct wl_display *display)
|
||||||
{
|
{
|
||||||
wl_list_init(&queue->event_list);
|
wl_list_init(&queue->event_list);
|
||||||
|
wl_list_init(&queue->proxy_list);
|
||||||
queue->display = display;
|
queue->display = display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -435,6 +438,8 @@ proxy_create(struct wl_proxy *factory, const struct wl_interface *interface,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link);
|
||||||
|
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -494,6 +499,8 @@ wl_proxy_create_for_id(struct wl_proxy *factory,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link);
|
||||||
|
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -518,6 +525,9 @@ proxy_destroy(struct wl_proxy *proxy)
|
||||||
|
|
||||||
proxy->flags |= WL_PROXY_FLAG_DESTROYED;
|
proxy->flags |= WL_PROXY_FLAG_DESTROYED;
|
||||||
|
|
||||||
|
wl_list_remove(&proxy->queue_link);
|
||||||
|
wl_list_init(&proxy->queue_link);
|
||||||
|
|
||||||
wl_proxy_unref(proxy);
|
wl_proxy_unref(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2335,6 +2345,8 @@ wl_proxy_set_queue(struct wl_proxy *proxy, struct wl_event_queue *queue)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&proxy->display->mutex);
|
pthread_mutex_lock(&proxy->display->mutex);
|
||||||
|
|
||||||
|
wl_list_remove(&proxy->queue_link);
|
||||||
|
|
||||||
if (queue) {
|
if (queue) {
|
||||||
assert(proxy->display == queue->display);
|
assert(proxy->display == queue->display);
|
||||||
proxy->queue = queue;
|
proxy->queue = queue;
|
||||||
|
|
@ -2342,6 +2354,8 @@ wl_proxy_set_queue(struct wl_proxy *proxy, struct wl_event_queue *queue)
|
||||||
proxy->queue = &proxy->display->default_queue;
|
proxy->queue = &proxy->display->default_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link);
|
||||||
|
|
||||||
pthread_mutex_unlock(&proxy->display->mutex);
|
pthread_mutex_unlock(&proxy->display->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2413,6 +2427,8 @@ wl_proxy_create_wrapper(void *proxy)
|
||||||
wrapper->flags = WL_PROXY_FLAG_WRAPPER;
|
wrapper->flags = WL_PROXY_FLAG_WRAPPER;
|
||||||
wrapper->refcount = 1;
|
wrapper->refcount = 1;
|
||||||
|
|
||||||
|
wl_list_insert(&wrapper->queue->proxy_list, &wrapper->queue_link);
|
||||||
|
|
||||||
pthread_mutex_unlock(&wrapped_proxy->display->mutex);
|
pthread_mutex_unlock(&wrapped_proxy->display->mutex);
|
||||||
|
|
||||||
return wrapper;
|
return wrapper;
|
||||||
|
|
@ -2434,6 +2450,12 @@ wl_proxy_wrapper_destroy(void *proxy_wrapper)
|
||||||
|
|
||||||
assert(wrapper->refcount == 1);
|
assert(wrapper->refcount == 1);
|
||||||
|
|
||||||
|
pthread_mutex_lock(&wrapper->display->mutex);
|
||||||
|
|
||||||
|
wl_list_remove(&wrapper->queue_link);
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&wrapper->display->mutex);
|
||||||
|
|
||||||
free(wrapper);
|
free(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue