aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-09-30 17:18:18 -0400
committerGitHub <noreply@github.com>2017-09-30 17:18:18 -0400
commit933cffaa8de0b43b71fa96437f6c5b1413ec0716 (patch)
tree634d23c6725f766d34a2c95343412b6ca9f02d15
parenta471ed3ed0915ee3dd0afd1b686d6cec975f89f4 (diff)
parent28f7256148eee495ffb554efa0365549f944e12e (diff)
Merge pull request #181 from acrisci/bug/toplevel-cleanup
xdg-toplevel: fix memory leaks
-rw-r--r--types/wlr_xdg_shell_v6.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c
index 9f623420..ea8d7976 100644
--- a/types/wlr_xdg_shell_v6.c
+++ b/types/wlr_xdg_shell_v6.c
@@ -219,6 +219,21 @@ static const struct zxdg_toplevel_v6_interface zxdg_toplevel_v6_implementation =
static void xdg_surface_destroy(struct wlr_xdg_surface_v6 *surface) {
wl_signal_emit(&surface->events.destroy, surface);
wl_resource_set_user_data(surface->resource, NULL);
+
+ if (surface->configure_idle) {
+ wl_event_source_remove(surface->configure_idle);
+ }
+
+ struct wlr_xdg_surface_v6_configure *configure, *tmp;
+ wl_list_for_each_safe(configure, tmp, &surface->configure_list, link) {
+ free(configure);
+ }
+
+ if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
+ wl_resource_set_user_data(surface->toplevel_state->resource, NULL);
+ free(surface->toplevel_state);
+ }
+
wl_list_remove(&surface->link);
wl_list_remove(&surface->surface_destroy_listener.link);
wl_list_remove(&surface->surface_commit_listener.link);
@@ -236,6 +251,13 @@ static void xdg_surface_resource_destroy(struct wl_resource *resource) {
}
}
+static void xdg_toplevel_resource_destroy(struct wl_resource *resource) {
+ struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
+ if (surface != NULL) {
+ xdg_surface_destroy(surface);
+ }
+}
+
static void xdg_surface_get_toplevel(struct wl_client *client,
struct wl_resource *resource, uint32_t id) {
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
@@ -260,7 +282,8 @@ static void xdg_surface_get_toplevel(struct wl_client *client,
surface->toplevel_state->resource = toplevel_resource;
wl_resource_set_implementation(toplevel_resource,
- &zxdg_toplevel_v6_implementation, surface, NULL);
+ &zxdg_toplevel_v6_implementation, surface,
+ xdg_toplevel_resource_destroy);
}
static void xdg_surface_get_popup(struct wl_client *client,