Don't panic when render state is unexpected

Crashed after waking from sleep, hopefully this fixes that
This commit is contained in:
Ottatop 2024-05-28 17:03:22 -05:00
parent c597ff6cce
commit d5343cab92

View file

@ -767,9 +767,10 @@ struct DrmSurfaceDmabufFeedback {
}
/// The state of a [`RenderSurface`].
#[derive(Debug)]
#[derive(Debug, Default)]
enum RenderState {
/// No render is scheduled.
#[default]
Idle,
// TODO: remove the token on tty switch or output unplug
/// A render has been queued.
@ -1322,12 +1323,15 @@ impl Udev {
}
};
let RenderState::WaitingForVblank { dirty } = surface.render_state else {
unreachable!();
let dirty = match std::mem::take(&mut surface.render_state) {
RenderState::WaitingForVblank { dirty } => dirty,
state => {
debug!("vblank happened but render state was {state:?}",);
self.schedule_render(&pinnacle.loop_handle, &output);
return;
}
};
surface.render_state = RenderState::Idle;
if dirty {
self.schedule_render(&pinnacle.loop_handle, &output);
} else {