bugfix(x11): crash when querying xsettings prop fails

Don't crash when xsettings query fails with _present_ xsettings.

Closes: https://github.com/rust-windowing/winit/issues/3573
This commit is contained in:
Kirill Chibisov 2024-03-07 22:14:33 +04:00 committed by John Nunley
parent 563b0bf5e3
commit 359a38844b
5 changed files with 43 additions and 16 deletions

View file

@ -887,6 +887,9 @@ pub enum X11Error {
/// Unable to parse xsettings.
XsettingsParse(xsettings::ParserError),
/// Failed to get property.
GetProperty(util::GetPropertyError),
}
impl fmt::Display for X11Error {
@ -896,6 +899,7 @@ impl fmt::Display for X11Error {
X11Error::Connect(e) => write!(f, "X11 connection error: {}", e),
X11Error::Connection(e) => write!(f, "X11 connection error: {}", e),
X11Error::XidsExhausted(e) => write!(f, "XID range exhausted: {}", e),
X11Error::GetProperty(e) => write!(f, "Failed to get X property {}", e),
X11Error::X11(e) => write!(f, "X11 error: {:?}", e),
X11Error::UnexpectedNull(s) => write!(f, "Xlib function returned null: {}", s),
X11Error::InvalidActivationToken(s) => write!(
@ -988,6 +992,12 @@ impl From<xsettings::ParserError> for X11Error {
}
}
impl From<util::GetPropertyError> for X11Error {
fn from(value: util::GetPropertyError) -> Self {
Self::GetProperty(value)
}
}
/// Type alias for a void cookie.
type VoidCookie<'a> = x11rb::cookie::VoidCookie<'a, X11rbConnection>;