backend/multi: emit destroy signal before destroying child backends

Some users might want to destroy the multi backend when a child
backend is being destroyed. However, they can't destroy the multi
backend if it's already in the process of being destroyed.

The destroy signal was changed to be emitted after destroying child
backends in babdd6ccf7 ("backend: fix use-after-free when destroying
backends"). However, this was done to accomodate for an old
"output_remove" event on backends, which has long been dropped in
favor of wlr_output.events.destroy.

This patch follows the same principle as 5d639394f3
("types/output: emit destroy event before destroying global").
master
Simon Ser 10 months ago
parent 7c080c3b60
commit a82fc4cb8f

@ -50,6 +50,8 @@ static void multi_backend_destroy(struct wlr_backend *wlr_backend) {
wl_list_remove(&backend->display_destroy.link); wl_list_remove(&backend->display_destroy.link);
wlr_backend_finish(wlr_backend);
// Some backends may depend on other backends, ie. destroying a backend may // Some backends may depend on other backends, ie. destroying a backend may
// also destroy other backends // also destroy other backends
while (!wl_list_empty(&backend->backends)) { while (!wl_list_empty(&backend->backends)) {
@ -58,8 +60,6 @@ static void multi_backend_destroy(struct wlr_backend *wlr_backend) {
wlr_backend_destroy(sub->backend); wlr_backend_destroy(sub->backend);
} }
// Destroy this backend only after removing all sub-backends
wlr_backend_finish(wlr_backend);
free(backend); free(backend);
} }

Loading…
Cancel
Save