client: fix crash when creating proxies with no queue

Before, it worked if the client did set a queue on the proxy before any event was received.
Now we have the "warning: queue xxx destroyed while proxies still attached", then a crash if one of
the proxies is used to create a proxy.

Fixes: 674145dc3f ("client: Track the proxies attached to a queue")
Fixes: 0ba650202e ("client: Warn when a queue is destroyed with attached proxies")
Signed-off-by: Loïc Yhuel <loic.yhuel@softathome.com>
This commit is contained in:
Loïc Yhuel 2025-09-16 13:15:34 +02:00
parent d81525a235
commit bf7b88caf3

View file

@ -499,7 +499,10 @@ proxy_create(struct wl_proxy *factory, const struct wl_interface *interface,
return NULL;
}
wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link);
if (proxy->queue != NULL)
wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link);
else
wl_list_init(&proxy->queue_link);
return proxy;
}
@ -560,7 +563,10 @@ wl_proxy_create_for_id(struct wl_proxy *factory,
return NULL;
}
wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link);
if (proxy->queue != NULL)
wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link);
else
wl_list_init(&proxy->queue_link);
return proxy;
}
@ -2801,7 +2807,10 @@ wl_proxy_create_wrapper(void *proxy)
wrapper->flags = WL_PROXY_FLAG_WRAPPER;
wrapper->refcount = 1;
wl_list_insert(&wrapper->queue->proxy_list, &wrapper->queue_link);
if (wrapper->queue != NULL)
wl_list_insert(&wrapper->queue->proxy_list, &wrapper->queue_link);
else
wl_list_init(&wrapper->queue_link);
pthread_mutex_unlock(&wrapped_proxy->display->mutex);