Fix crash due to wrong drop order of clipboard

Fixes #7309.
This commit is contained in:
Kirill Chibisov 2023-10-23 00:18:16 +04:00 committed by GitHub
parent 80d4daccc3
commit d66db480cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -1551,14 +1551,15 @@ impl Processor {
let mut scheduler = Scheduler::new(proxy.clone()); let mut scheduler = Scheduler::new(proxy.clone());
let mut initial_window_options = Some(initial_window_options); 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. // Disable all device events, since we don't care about them.
event_loop.listen_device_events(DeviceEvents::Never); event_loop.listen_device_events(DeviceEvents::Never);
let mut initial_window_error = Ok(()); 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 { if self.config.debug.print_events {
info!("winit event: {:?}", event); info!("winit event: {:?}", event);
} }
@ -1584,7 +1585,7 @@ impl Processor {
proxy.clone(), proxy.clone(),
initial_window_options, initial_window_options,
) { ) {
initial_window_error = Err(err); *initial_window_error_loop = Err(err);
event_loop.exit(); event_loop.exit();
return; return;
} }