diff options
author | Alexander Orzechowski <alex@ozal.ski> | 2023-10-05 05:14:54 -0400 |
---|---|---|
committer | Alexander Orzechowski <alex@ozal.ski> | 2023-10-05 05:14:54 -0400 |
commit | d817ebb80f8b0f1a27152104525d4b5a8c38e56d (patch) | |
tree | d5d8de4475f1d5de8b3452444da7fb0f73311075 | |
parent | 4f92ecde8290fd98572716f13c6eadf612a6a029 (diff) |
renderer: Don't crash when trying to fallback to pixman
Pixman won't be chosen by default if the system has a valid render node
but gles2 and vulkan creation failed.
-rw-r--r-- | render/wlr_renderer.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index 36837eda..c4332ac0 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -346,6 +346,23 @@ static void log_creation_failure(bool is_auto, const char *msg) { wlr_log(is_auto ? WLR_DEBUG : WLR_ERROR, "%s%s", msg, is_auto ? ". Skipping!" : ""); } +static bool has_render_node(struct wlr_backend *backend) { + if (!backend) { + return false; + } + + int backend_drm_fd = wlr_backend_get_drm_fd(backend); + if (backend_drm_fd < 0) { + return false; + } + + char *render_node = drmGetRenderDeviceNameFromFd(backend_drm_fd); + bool has_render_node = render_node != NULL; + free(render_node); + + return has_render_node; +} + static struct wlr_renderer *renderer_autocreate(struct wlr_backend *backend, int drm_fd) { const char *renderer_options[] = { "auto", @@ -396,15 +413,7 @@ static struct wlr_renderer *renderer_autocreate(struct wlr_backend *backend, int } #endif - bool has_render_node = false; - int backend_drm_fd = wlr_backend_get_drm_fd(backend); - if (is_auto && backend_drm_fd >= 0) { - char *render_node = drmGetRenderDeviceNameFromFd(backend_drm_fd); - has_render_node = render_node != NULL; - free(render_node); - } - - if ((is_auto && !has_render_node) || strcmp(renderer_name, "pixman") == 0) { + if ((is_auto && !has_render_node(backend)) || strcmp(renderer_name, "pixman") == 0) { renderer = wlr_pixman_renderer_create(); if (renderer) { goto out; |