diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2023-10-23 00:18:16 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-23 00:18:16 +0400 |
commit | d66db480cfc8a8e3965358199ae8e247a433dffb (patch) | |
tree | 6d04b66957344e2410c53264f0f406fa21c885c7 | |
parent | 80d4daccc307622f8e604af4f36ac89ecccf5db7 (diff) | |
download | alacritty-d66db480cfc8a8e3965358199ae8e247a433dffb.tar.gz alacritty-d66db480cfc8a8e3965358199ae8e247a433dffb.zip |
Fix crash due to wrong drop order of clipboard
Fixes #7309.
-rw-r--r-- | alacritty/src/event.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index b7a87855..6f82be11 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -1551,14 +1551,15 @@ impl Processor { let mut scheduler = Scheduler::new(proxy.clone()); let mut initial_window_options = Some(initial_window_options); - // NOTE: Since this takes a pointer to the winit event loop, it MUST be dropped first. - let mut clipboard = unsafe { Clipboard::new(event_loop.raw_display_handle()) }; - // Disable all device events, since we don't care about them. event_loop.listen_device_events(DeviceEvents::Never); let mut initial_window_error = Ok(()); - let result = event_loop.run(|event, event_loop| { + let initial_window_error_loop = &mut initial_window_error; + // SAFETY: Since this takes a pointer to the winit event loop, it MUST be dropped first, + // which is done by `move` into event loop. + let mut clipboard = unsafe { Clipboard::new(event_loop.raw_display_handle()) }; + let result = event_loop.run(move |event, event_loop| { if self.config.debug.print_events { info!("winit event: {:?}", event); } @@ -1584,7 +1585,7 @@ impl Processor { proxy.clone(), initial_window_options, ) { - initial_window_error = Err(err); + *initial_window_error_loop = Err(err); event_loop.exit(); return; } |