Skip to content

Commit

Permalink
Fix: don't early out if screenshotting fails
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jan 29, 2024
1 parent 7938ac1 commit 8886870
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crates/egui-wgpu/src/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,11 @@ impl Painter {
render_state,
);
self.screen_capture_state
.as_ref()?
.texture
.as_ref()
.map_or_else(
|| &output_frame.texture,
|capture_state| &capture_state.texture,
)
.create_view(&wgpu::TextureViewDescriptor::default())
} else {
output_frame
Expand Down Expand Up @@ -660,8 +663,11 @@ impl Painter {
};

let screenshot = if capture {
let screen_capture_state = self.screen_capture_state.as_ref()?;
Self::read_screen_rgba(screen_capture_state, render_state, &output_frame)
self.screen_capture_state
.as_ref()
.and_then(|screen_capture_state| {
Self::read_screen_rgba(screen_capture_state, render_state, &output_frame)
})
} else {
None
};
Expand Down

0 comments on commit 8886870

Please sign in to comment.