diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-01-19 09:13:32 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-01-19 09:13:32 +0400 |
| commit | 475b3df2b5bd660f9137cf28b6de571d4dad90e6 (patch) | |
| tree | b6e7af30a69be765ad4ca7eff5a33ea05ca1197f /src/cursor.rs | |
| parent | 1541835f00089ce19af289643dd517c48f5beba9 (diff) | |
| download | niri-475b3df2b5bd660f9137cf28b6de571d4dad90e6.tar.gz niri-475b3df2b5bd660f9137cf28b6de571d4dad90e6.tar.bz2 niri-475b3df2b5bd660f9137cf28b6de571d4dad90e6.zip | |
Don't crash when failing to render a cursor
I only hit this when the renderer was completely busted, but
nevertheless.
Diffstat (limited to 'src/cursor.rs')
| -rw-r--r-- | src/cursor.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/cursor.rs b/src/cursor.rs index 6bf92cd1..bdaba542 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -224,7 +224,7 @@ pub enum RenderCursor { }, } -type TextureCache = HashMap<(CursorIcon, i32), Vec<TextureBuffer<GlesTexture>>>; +type TextureCache = HashMap<(CursorIcon, i32), Vec<Option<TextureBuffer<GlesTexture>>>>; #[derive(Default)] pub struct CursorTextureCache { @@ -243,7 +243,7 @@ impl CursorTextureCache { scale: i32, cursor: &XCursor, idx: usize, - ) -> TextureBuffer<GlesTexture> { + ) -> Option<TextureBuffer<GlesTexture>> { self.cache .borrow_mut() .entry((icon, scale)) @@ -254,7 +254,7 @@ impl CursorTextureCache { .map(|frame| { let _span = tracy_client::span!("create TextureBuffer"); - TextureBuffer::from_memory( + let buffer = TextureBuffer::from_memory( renderer, &frame.pixels_rgba, Fourcc::Abgr8888, @@ -263,8 +263,15 @@ impl CursorTextureCache { scale, Transform::Normal, None, - ) - .unwrap() + ); + + match buffer { + Ok(x) => Some(x), + Err(err) => { + warn!("error creating a cursor texture: {err:?}"); + None + } + } }) .collect() })[idx] |
