aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/backend.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/backend/backend.c b/backend/backend.c
index 359ee0e5..6b32bc6a 100644
--- a/backend/backend.c
+++ b/backend/backend.c
@@ -33,6 +33,10 @@ bool wlr_backend_start(struct wlr_backend *backend) {
}
void wlr_backend_destroy(struct wlr_backend *backend) {
+ if (!backend) {
+ return;
+ }
+
wl_signal_emit(&backend->events.destroy, backend);
if (backend->impl && backend->impl->destroy) {
backend->impl->destroy(backend);
@@ -82,6 +86,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
struct wlr_backend *wl_backend = attempt_wl_backend(display);
if (wl_backend) {
wlr_multi_backend_add(backend, wl_backend);
+ return backend;
}
}
@@ -90,18 +95,25 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
struct wlr_backend *x11_backend =
wlr_x11_backend_create(display, x11_display);
wlr_multi_backend_add(backend, x11_backend);
+ return backend;
}
// Attempt DRM+libinput
struct wlr_session *session = wlr_session_create(display);
if (!session) {
wlr_log(L_ERROR, "Failed to start a DRM session");
- goto out;
+ wlr_backend_destroy(backend);
+ return NULL;
}
struct wlr_backend *libinput = wlr_libinput_backend_create(display, session);
if (libinput) {
wlr_multi_backend_add(backend, libinput);
+ } else {
+ wlr_log(L_ERROR, "Failed to start libinput backend");
+ wlr_backend_destroy(backend);
+ wlr_session_destroy(session);
+ return NULL;
}
int gpus[8];
@@ -126,10 +138,8 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
if (!primary_drm) {
wlr_log(L_ERROR, "Failed to open any DRM device");
- }
-
-out:
- if (wlr_multi_is_empty(backend)) {
+ wlr_backend_destroy(libinput);
+ wlr_session_destroy(session);
wlr_backend_destroy(backend);
return NULL;
}