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.
This commit is contained in:
Dudemanguy 2023-07-08 20:31:09 -05:00
parent 6a365b258a
commit 0242055564
1 changed files with 5 additions and 7 deletions

View File

@ -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);