Listen to display destroy in session

It's not the backend's responsibility to destroy the session anymore.
This commit is contained in:
emersion 2017-12-08 11:17:56 +01:00
parent e30b943fbd
commit 6001235b04
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
3 changed files with 14 additions and 2 deletions

View File

@ -35,7 +35,6 @@ static void multi_backend_destroy(struct wlr_backend *_backend) {
wlr_backend_destroy(sub->backend); wlr_backend_destroy(sub->backend);
free(sub); free(sub);
} }
wlr_session_destroy(backend->session);
free(backend); free(backend);
} }

View File

@ -58,6 +58,12 @@ out:
return 1; return 1;
} }
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_session *session =
wl_container_of(listener, session, display_destroy);
wlr_session_destroy(session);
}
struct wlr_session *wlr_session_create(struct wl_display *disp) { struct wlr_session *wlr_session_create(struct wl_display *disp) {
struct wlr_session *session = NULL; struct wlr_session *session = NULL;
const struct session_impl **iter; const struct session_impl **iter;
@ -100,6 +106,9 @@ struct wlr_session *wlr_session_create(struct wl_display *disp) {
goto error_mon; goto error_mon;
} }
session->display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(disp, &session->display_destroy);
return session; return session;
error_mon: error_mon:
@ -107,7 +116,7 @@ error_mon:
error_udev: error_udev:
udev_unref(session->udev); udev_unref(session->udev);
error_session: error_session:
wlr_session_destroy(session); session->impl->destroy(session);
return NULL; return NULL;
} }
@ -116,6 +125,8 @@ void wlr_session_destroy(struct wlr_session *session) {
return; return;
} }
wl_list_remove(&session->display_destroy.link);
wl_event_source_remove(session->udev_event); wl_event_source_remove(session->udev_event);
udev_monitor_unref(session->mon); udev_monitor_unref(session->mon);
udev_unref(session->udev); udev_unref(session->udev);

View File

@ -33,6 +33,8 @@ struct wlr_session {
struct wl_event_source *udev_event; struct wl_event_source *udev_event;
struct wl_list devices; struct wl_list devices;
struct wl_listener display_destroy;
}; };
/* /*