screencopy: Handle error from with_buffer_contents_mut

Fixes https://github.com/pop-os/cosmic-comp/issues/48.

https://github.com/Smithay/smithay/pull/1475 fixes the segfault so this
instead produces an error. Then we need to handle the error here.
This commit is contained in:
Ian Douglas Scott 2024-07-03 14:35:32 -07:00 committed by Victoria Brekenfeld
parent f02520c194
commit 9f8fec6ec5
3 changed files with 7 additions and 4 deletions

2
Cargo.lock generated
View file

@ -4856,7 +4856,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]] [[package]]
name = "smithay" name = "smithay"
version = "0.3.0" version = "0.3.0"
source = "git+https://github.com/smithay//smithay?rev=3731734#3731734d5a0409186a0475238ffe46e2835cee6d" source = "git+https://github.com/smithay//smithay?rev=4171247#41712470abede74dab8a039ce048c70d56115ce6"
dependencies = [ dependencies = [
"appendlist", "appendlist",
"ash 0.38.0+1.3.281", "ash 0.38.0+1.3.281",

View file

@ -119,4 +119,4 @@ inherits = "release"
lto = "fat" lto = "fat"
[patch."https://github.com/Smithay/smithay.git"] [patch."https://github.com/Smithay/smithay.git"]
smithay = {git = "https://github.com/smithay//smithay", rev = "3731734"} smithay = {git = "https://github.com/smithay//smithay", rev = "4171247"}

View file

@ -9,7 +9,7 @@ use smithay::{
utils::{Relocate, RelocateRenderElement}, utils::{Relocate, RelocateRenderElement},
AsRenderElements, RenderElement, AsRenderElements, RenderElement,
}, },
gles::GlesRenderbuffer, gles::{GlesError, GlesRenderbuffer},
sync::SyncPoint, sync::SyncPoint,
utils::with_renderer_surface_state, utils::with_renderer_surface_state,
Bind, Blit, BufferType, ExportMem, ImportAll, ImportMem, Offscreen, Renderer, Bind, Blit, BufferType, ExportMem, ImportAll, ImportMem, Offscreen, Renderer,
@ -63,6 +63,7 @@ pub fn submit_buffer<R>(
) -> Result<Option<(Frame, Vec<Rectangle<i32, BufferCoords>>)>, <R as Renderer>::Error> ) -> Result<Option<(Frame, Vec<Rectangle<i32, BufferCoords>>)>, <R as Renderer>::Error>
where where
R: ExportMem, R: ExportMem,
<R as Renderer>::Error: FromGlesError,
{ {
let Some(damage) = damage else { let Some(damage) = damage else {
frame.success( frame.success(
@ -113,7 +114,8 @@ where
} }
Ok(()) Ok(())
}) })
.unwrap() .map_err(|err| <R as Renderer>::Error::from_gles_error(GlesError::BufferAccessError(err)))
.and_then(|x| x)
{ {
frame.fail(FailureReason::Unknown); frame.fail(FailureReason::Unknown);
return Err(err); return Err(err);
@ -141,6 +143,7 @@ pub fn render_session<F, R>(
) -> Result<Option<(Frame, Vec<Rectangle<i32, BufferCoords>>)>, DTError<R>> ) -> Result<Option<(Frame, Vec<Rectangle<i32, BufferCoords>>)>, DTError<R>>
where where
R: ExportMem, R: ExportMem,
<R as Renderer>::Error: FromGlesError,
F: for<'d> FnOnce( F: for<'d> FnOnce(
&WlBuffer, &WlBuffer,
&mut R, &mut R,