diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 7e8e7a62..d9907de0 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -1637,6 +1637,8 @@ void weston_layer_init(struct weston_layer *layer, struct weston_compositor *compositor); void +weston_layer_fini(struct weston_layer *layer); +void weston_layer_set_position(struct weston_layer *layer, enum weston_layer_position position); void diff --git a/libweston/compositor.c b/libweston/compositor.c index dc6ecb2c..c2da3a48 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -3243,6 +3243,21 @@ weston_layer_init(struct weston_layer *layer, weston_layer_set_mask_infinite(layer); } +/** Finalize the weston_layer struct. + * + * \param layer The layer to finalize. + */ +WL_EXPORT void +weston_layer_fini(struct weston_layer *layer) +{ + wl_list_remove(&layer->link); + + if (!wl_list_empty(&layer->view_list.link)) + weston_log("BUG: finalizing a layer with views still on it.\n"); + + wl_list_remove(&layer->view_list.link); +} + /** Sets the position of the layer in the layer list. The layer will be placed * below any layer with the same position value, if any. * This function is safe to call if the layer is already on the list, but the @@ -7738,6 +7753,12 @@ weston_compositor_shutdown(struct weston_compositor *ec) weston_binding_list_destroy_all(&ec->debug_binding_list); weston_plane_release(&ec->primary_plane); + + weston_layer_fini(&ec->fade_layer); + weston_layer_fini(&ec->cursor_layer); + + if (!wl_list_empty(&ec->layer_list)) + weston_log("BUG: layer_list is not empty after shutdown. Calls to weston_layer_fini() are missing somwhere.\n"); } /** weston_compositor_exit_with_code