aboutsummaryrefslogtreecommitdiff
path: root/backend/multi
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-05-02 16:42:26 +0200
committerDrew DeVault <sir@cmpwn.com>2020-05-02 19:36:03 +0200
commit7720ce7827e8bdaaf42f72fb29ecf91a2d3c2294 (patch)
treeed8b2ef159cbf3895283526c9005c1637a42dcc4 /backend/multi
parente3343cf7d1e0d8c429046887b4fc90be35b9cfba (diff)
backend/multi: handle backends depending on each other properly
wl_list_for_each_safe only allows the current list item to be removed. If a backend destroys itself when another backend is destroyed, this blows up.
Diffstat (limited to 'backend/multi')
-rw-r--r--backend/multi/backend.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/backend/multi/backend.c b/backend/multi/backend.c
index 7ba25ca8..6289f107 100644
--- a/backend/multi/backend.c
+++ b/backend/multi/backend.c
@@ -49,8 +49,11 @@ static void multi_backend_destroy(struct wlr_backend *wlr_backend) {
wl_list_remove(&backend->display_destroy.link);
- struct subbackend_state *sub, *next;
- wl_list_for_each_safe(sub, next, &backend->backends, link) {
+ // Some backends may depend on other backends, ie. destroying a backend may
+ // also destroy other backends
+ while (!wl_list_empty(&backend->backends)) {
+ struct subbackend_state *sub =
+ wl_container_of(backend->backends.next, sub, link);
wlr_backend_destroy(sub->backend);
}