summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-07-08 20:31:09 -0500
committerDudemanguy <random342@airmail.cc>2023-07-08 20:31:09 -0500
commit024205556448393e64e5020e41e7be498535c566 (patch)
tree0108424a37a9ae419829b384f66ed6c3dc040423 /video/out
parent6a365b258ac77d7e4759e0ae14ccc9e882c4c86f (diff)
downloadmpv-024205556448393e64e5020e41e7be498535c566.tar.bz2
mpv-024205556448393e64e5020e41e7be498535c566.tar.xz
wayland: fix memory leak with multiple monitors
Very dumb. I can't remember if it was always like this or if I broke it at some point, but clearly each wl_output should just be freed in remove_output. Freeing it if it happens to be wl->current_output only works for that one monitor, so remove that whole line. This has to happen before we close the wayland connection so reorder the uninit a little bit.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/wayland_common.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 28cd6eb55b..36dc0f6934 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1652,6 +1652,7 @@ static void remove_output(struct vo_wayland_output *out)
MP_VERBOSE(out->wl, "Deregistering output %s %s (0x%x)\n", out->make,
out->model, out->id);
wl_list_remove(&out->link);
+ wl_output_destroy(out->output);
talloc_free(out->make);
talloc_free(out->model);
talloc_free(out);
@@ -2314,9 +2315,6 @@ void vo_wayland_uninit(struct vo *vo)
if (wl->subcompositor)
wl_subcompositor_destroy(wl->subcompositor);
- if (wl->current_output && wl->current_output->output)
- wl_output_destroy(wl->current_output->output);
-
if (wl->cursor_surface)
wl_surface_destroy(wl->cursor_surface);
@@ -2431,6 +2429,10 @@ void vo_wayland_uninit(struct vo *vo)
if (wl->xkb_state)
xkb_state_unref(wl->xkb_state);
+ struct vo_wayland_output *output, *tmp;
+ wl_list_for_each_safe(output, tmp, &wl->output_list, link)
+ remove_output(output);
+
if (wl->display) {
close(wl_display_get_fd(wl->display));
wl_display_disconnect(wl->display);
@@ -2438,10 +2440,6 @@ void vo_wayland_uninit(struct vo *vo)
munmap(wl->format_map, wl->format_size);
- struct vo_wayland_output *output, *tmp;
- wl_list_for_each_safe(output, tmp, &wl->output_list, link)
- remove_output(output);
-
for (int n = 0; n < 2; n++)
close(wl->wakeup_pipe[n]);
talloc_free(wl);