linuxkms: Avoid keeping the EGL display around for too long

Don't keep a strong reference to the EGL display, we don't need that. If the display is removed but there are pending events, just ignore them.
This commit is contained in:
Simon Hausmann 2023-12-18 18:37:14 +01:00 committed by Simon Hausmann
parent 388661cc53
commit b998f94ad6

View file

@ -63,15 +63,18 @@ impl super::Presenter for EglDisplay {
self: Rc<Self>, self: Rc<Self>,
event_loop_handle: crate::calloop_backend::EventLoopHandle, event_loop_handle: crate::calloop_backend::EventLoopHandle,
) -> Result<calloop::RegistrationToken, PlatformError> { ) -> Result<calloop::RegistrationToken, PlatformError> {
let self_weak = Rc::downgrade(&self);
crate::calloop_backend::FileDescriptorActivityNotifier::new( crate::calloop_backend::FileDescriptorActivityNotifier::new(
&event_loop_handle, &event_loop_handle,
calloop::Interest::READ, calloop::Interest::READ,
self.gbm_device.0.clone(), self.gbm_device.0.clone(),
Box::new(move || { Box::new(move || {
for event in self.gbm_device.receive_events().unwrap() { if let Some(this) = self_weak.upgrade() {
if matches!(event, drm::control::Event::PageFlip(..)) { for event in this.gbm_device.receive_events().unwrap() {
*self.page_flip_state.borrow_mut() = PageFlipState::ReadyForNextBuffer; if matches!(event, drm::control::Event::PageFlip(..)) {
break; *this.page_flip_state.borrow_mut() = PageFlipState::ReadyForNextBuffer;
break;
}
} }
} }
}), }),