From d3a60e03c9f9ff5c8145c747552b4c85da7c4464 Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Mon, 18 May 2020 20:23:08 +0200 Subject: [PATCH] egl: differenciate display creation failures --- src/backend/egl/display.rs | 5 ++++- src/backend/egl/error.rs | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/backend/egl/display.rs b/src/backend/egl/display.rs index e416299..aa273b4 100644 --- a/src/backend/egl/display.rs +++ b/src/backend/egl/display.rs @@ -97,8 +97,11 @@ impl> EGLDisplay { |e: &str| dp_extensions.iter().any(|s| s == e), log.clone(), ) - .map_err(Error::DisplayNotSupported)? + .map_err(Error::DisplayCreationError)? }; + if display == ffi::egl::NO_DISPLAY { + return Err(Error::DisplayNotSupported); + } let egl_version = { let mut major: MaybeUninit = MaybeUninit::uninit(); diff --git a/src/backend/egl/error.rs b/src/backend/egl/error.rs index cc4c24d..938fc19 100644 --- a/src/backend/egl/error.rs +++ b/src/backend/egl/error.rs @@ -15,9 +15,12 @@ pub enum Error { /// Backend does not match the context type #[error("The expected backend '{0:?}' does not match the runtime")] NonMatchingBackend(&'static str), + /// Display creation failed + #[error("Display creation failed with error: {0:}")] + DisplayCreationError(#[source] EGLError), /// Unable to obtain a valid EGL Display - #[error("Unable to obtain a valid EGL Display. Err: {0:}")] - DisplayNotSupported(#[source] EGLError), + #[error("Unable to obtain a valid EGL Display.")] + DisplayNotSupported, /// `eglInitialize` returned an error #[error("Failed to initialize EGL. Err: {0:}")] InitFailed(#[source] EGLError),