mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 23:23:14 -04:00
Make with_x11_visual take ID instead of a pointer
At the moment, the with_x11_visual function takes a pointer and immediately dereferences it to get the visual info inside. As it is safe to pass a null pointer to this function, it is unsound. This commit replaces the pointer parameter with a visual ID, and then uses that ID to look up the actual visual under the X11 setup. As this is what was already practically happening before, this change shouldn't cause any performance downgrades. This is a breaking change, but it's done in the name of soundness so it should be okay. It should be trivial for end users to accommodate it, as it's just a matter of getting the visual ID from the pointer to the visual before passing it in. Signed-off-by: John Nunley <dev@notgull.net>
This commit is contained in:
committed by
Kirill Chibisov
parent
03bf83f45e
commit
2791cbd65e
@@ -886,6 +886,9 @@ pub enum X11Error {
|
||||
|
||||
/// Got an invalid activation token.
|
||||
InvalidActivationToken(Vec<u8>),
|
||||
|
||||
/// Could not find a matching X11 visual for this visualid
|
||||
NoSuchVisual(xproto::Visualid),
|
||||
}
|
||||
|
||||
impl fmt::Display for X11Error {
|
||||
@@ -902,6 +905,13 @@ impl fmt::Display for X11Error {
|
||||
"Invalid activation token: {}",
|
||||
std::str::from_utf8(s).unwrap_or("<invalid utf8>")
|
||||
),
|
||||
X11Error::NoSuchVisual(visualid) => {
|
||||
write!(
|
||||
f,
|
||||
"Could not find a matching X11 visual for ID `{:x}`",
|
||||
visualid
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user