Skip to content

Commit

Permalink
surface: Don't crash due to weird state after resume
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Aug 8, 2024
1 parent 7660f7a commit d580294
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/backend/kms/surface/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,27 @@ impl SurfaceThreadState {
let Some(compositor) = self.compositor.as_mut() else {
return;
};

// handle edge-cases right after resume
if !matches!(
self.state,
QueueState::WaitingForVBlank { .. } | QueueState::Idle
) {
match mem::replace(&mut self.state, QueueState::Idle) {
QueueState::WaitingForVBlank { .. } | QueueState::Idle => unreachable!(),
QueueState::Queued(token) | QueueState::WaitingForEstimatedVBlank(token) => {
self.loop_handle.remove(token);
}
QueueState::WaitingForEstimatedVBlankAndQueued {
estimated_vblank,
queued_render,
} => {
self.loop_handle.remove(estimated_vblank);
self.loop_handle.remove(queued_render);
}
}
}
if matches!(self.state, QueueState::Idle) {
// can happen right after resume
return;
}

Expand Down

0 comments on commit d580294

Please sign in to comment.