commit b5b7214

Michael Forney  ·  2020-02-22 10:04:33 +0000 UTC
parent bafe1eb
xdg_decoration: Free decoration when it is destroyed
1 files changed,  +10, -1
+10, -1
 1@@ -55,6 +55,15 @@ handle_toplevel_destroy(struct wl_listener *listener, void *data)
 2 	wl_resource_destroy(decoration->resource);
 3 }
 4 
 5+static void
 6+decoration_destroy(struct wl_resource *resource)
 7+{
 8+	struct xdg_toplevel_decoration *decoration = wl_resource_get_user_data(resource);
 9+
10+	wl_list_remove(&decoration->toplevel_destroy_listener.link);
11+	free(decoration);
12+}
13+
14 static void
15 get_toplevel_decoration(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *toplevel_resource)
16 {
17@@ -68,7 +77,7 @@ get_toplevel_decoration(struct wl_client *client, struct wl_resource *resource,
18 		goto error1;
19 	decoration->toplevel_destroy_listener.notify = &handle_toplevel_destroy;
20 	wl_resource_add_destroy_listener(toplevel_resource, &decoration->toplevel_destroy_listener);
21-	wl_resource_set_implementation(decoration->resource, &decoration_impl, NULL, NULL);
22+	wl_resource_set_implementation(decoration->resource, &decoration_impl, decoration, decoration_destroy);
23 	zxdg_toplevel_decoration_v1_send_configure(decoration->resource, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
24 	return;
25