compositor: Do not handle embedder events during or after shutdown (#32207)

This is a speculative fix for #32202, which I cannot reproduce
consistently. This prevents handling any embedder events while
shutting down or after shutdown is complete. It doesn't make sense to do
this as the compositor can be in a very inconsistent state during this
time and lead to panics.

Fixes ##32202.
This commit is contained in:
Martin Robinson 2024-05-02 05:58:15 +02:00 committed by GitHub
parent 50c2e18347
commit 0df79b939a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1416,6 +1416,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
}
pub fn on_mouse_window_event_class(&mut self, mouse_window_event: MouseWindowEvent) {
if self.shutdown_state != ShutdownState::NotShuttingDown {
return;
}
if self.convert_mouse_to_touch {
match mouse_window_event {
MouseWindowEvent::Click(_, _) => {},
@ -1513,6 +1517,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
}
pub fn on_mouse_window_move_event_class(&mut self, cursor: DevicePoint) {
if self.shutdown_state != ShutdownState::NotShuttingDown {
return;
}
if self.convert_mouse_to_touch {
self.on_touch_move(TouchId(0), cursor);
return;
@ -1571,6 +1579,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
identifier: TouchId,
location: DevicePoint,
) {
if self.shutdown_state != ShutdownState::NotShuttingDown {
return;
}
match event_type {
TouchEventType::Down => self.on_touch_down(identifier, location),
TouchEventType::Move => self.on_touch_move(identifier, location),
@ -1638,6 +1650,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
}
pub fn on_wheel_event(&mut self, delta: WheelDelta, p: DevicePoint) {
if self.shutdown_state != ShutdownState::NotShuttingDown {
return;
}
self.send_wheel_event(delta, p);
}
@ -1647,6 +1663,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
cursor: DeviceIntPoint,
phase: TouchEventType,
) {
if self.shutdown_state != ShutdownState::NotShuttingDown {
return;
}
match phase {
TouchEventType::Move => self.on_scroll_window_event(scroll_location, cursor),
TouchEventType::Up | TouchEventType::Cancel => {
@ -1860,11 +1880,19 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
}
pub fn on_zoom_reset_window_event(&mut self) {
if self.shutdown_state != ShutdownState::NotShuttingDown {
return;
}
self.page_zoom = Scale::new(1.0);
self.update_after_zoom_or_hidpi_change();
}
pub fn on_zoom_window_event(&mut self, magnification: f32) {
if self.shutdown_state != ShutdownState::NotShuttingDown {
return;
}
self.page_zoom = Scale::new(
(self.page_zoom.get() * magnification)
.max(MIN_ZOOM)
@ -1887,6 +1915,10 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
/// Simulate a pinch zoom
pub fn on_pinch_zoom_window_event(&mut self, magnification: f32) {
if self.shutdown_state != ShutdownState::NotShuttingDown {
return;
}
// TODO: Scroll to keep the center in view?
self.pending_scroll_zoom_events
.push(ScrollZoomEvent::PinchZoom(magnification));