File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
platform_impl/linux/wayland/event_loop Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -247,3 +247,4 @@ changelog entry.
247247- On macOS, fixed the scancode conversion for ` IntlBackslash ` .
248248- On macOS, fixed redundant ` SurfaceResized ` event at window creation.
249249- On Windows, fixed crash in should_apps_use_dark_mode() for Windows versions < 17763.
250+ - On Wayland, fixed ` pump_events ` driven loop deadlocking when loop was not drained before exit.
Original file line number Diff line number Diff line change @@ -739,7 +739,7 @@ impl Drop for PumpEventNotifier {
739739 if let Some ( worker_waker) = self . worker_waker . as_ref ( ) {
740740 let _ = rustix:: io:: write ( worker_waker. as_fd ( ) , & [ 0u8 ] ) ;
741741 }
742- * self . control . 0 . lock ( ) . unwrap ( ) = PumpEventNotifierAction :: Monitor ;
742+ * self . control . 0 . lock ( ) . unwrap ( ) = PumpEventNotifierAction :: Shutdown ;
743743 self . control . 1 . notify_one ( ) ;
744744
745745 if let Some ( handle) = self . handle . take ( ) {
@@ -767,6 +767,14 @@ impl PumpEventNotifier {
767767 while * wait == PumpEventNotifierAction :: Pause {
768768 wait = cvar. wait ( wait) . unwrap ( ) ;
769769 }
770+
771+ // Exit the loop when we're asked to. Given that we poll
772+ // only once we can take the `prepare_read`, but in some cases
773+ // it could be not possible, we may block on `join`.
774+ if * wait == PumpEventNotifierAction :: Shutdown {
775+ break ' outer;
776+ }
777+
770778 // Wake-up the main loop and put this one back to sleep.
771779 * wait = PumpEventNotifierAction :: Pause ;
772780 drop ( wait) ;
@@ -802,4 +810,6 @@ enum PumpEventNotifierAction {
802810 Monitor ,
803811 /// Pause monitoring.
804812 Pause ,
813+ /// Shutdown the thread.
814+ Shutdown ,
805815}
You can’t perform that action at this time.
0 commit comments