- ProxyT *proxy;
-
- wayland_proxy(void *p) : proxy(static_cast<ProxyT *>(p)) {}
-
- virtual ~wayland_proxy() {
- // If this is the nullptr, then it means it already was destroyed by a
- // custom wayland dtor
- if (this->proxy) {
- logdebug("%s %p @ %p", __func__, this, this->proxy);
- wl_proxy_destroy(reinterpret_cast<struct wl_proxy *>(this->proxy));
- }
- }
+ std::unique_ptr<ProxyT, std::function<void(ProxyT *)>> proxy;
+ wayland_proxy(wayland_proxy const &) = delete;
+ wayland_proxy &operator=(wayland_proxy const &) = delete;
+ wayland_proxy(void *p)
+ : wayland_proxy(p,
+ reinterpret_cast<void (*)(ProxyT *)>(wl_proxy_destroy)) {}
+ wayland_proxy(void *p, std::function<void(ProxyT *)> &&p_del)
+ : proxy(std::unique_ptr<ProxyT, std::function<void(ProxyT *)>>(
+ static_cast<ProxyT *>(p), p_del)) {}