mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 21:31:29 +11:00
Fix a panic due to double-borrow
This commit is contained in:
parent
182beb4f8b
commit
b571362bf1
|
@ -77,3 +77,6 @@ version = "0.8"
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
stdweb = { path = "../stdweb", optional = true }
|
stdweb = { path = "../stdweb", optional = true }
|
||||||
instant = { version = "0.1", features = ["stdweb"] }
|
instant = { version = "0.1", features = ["stdweb"] }
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
stdweb = { path = "../stdweb" }
|
||||||
|
|
|
@ -333,9 +333,9 @@ impl<T: 'static> EventLoopRunnerShared<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if event handling is in process, and then release the borrow on the runner
|
// Determine if event handling is in process, and then release the borrow on the runner
|
||||||
match *self.0.runner.borrow() {
|
let (start_cause, event_is_start) = match *self.0.runner.borrow() {
|
||||||
Some(ref runner) if !runner.is_busy => {
|
Some(ref runner) if !runner.is_busy => {
|
||||||
let (start_cause, event_is_start) = if let Event::NewEvents(cause) = event {
|
if let Event::NewEvents(cause) = event {
|
||||||
(cause, true)
|
(cause, true)
|
||||||
} else {
|
} else {
|
||||||
(match runner.control {
|
(match runner.control {
|
||||||
|
@ -359,8 +359,16 @@ impl<T: 'static> EventLoopRunnerShared<T> {
|
||||||
},
|
},
|
||||||
ControlFlowStatus::Exit => { return; }
|
ControlFlowStatus::Exit => { return; }
|
||||||
}, false)
|
}, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
// Events are currently being handled, so queue this one and don't try to
|
||||||
|
// double-process the event queue
|
||||||
|
self.0.events.borrow_mut().push_back(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let mut control = runner.control.to_control_flow();
|
let mut control = self.current_control_flow();
|
||||||
// Handle starting a new batch of events
|
// Handle starting a new batch of events
|
||||||
//
|
//
|
||||||
// The user is informed via Event::NewEvents that there is a batch of events to process
|
// The user is informed via Event::NewEvents that there is a batch of events to process
|
||||||
|
@ -370,20 +378,13 @@ impl<T: 'static> EventLoopRunnerShared<T> {
|
||||||
self.handle_event(event, &mut control);
|
self.handle_event(event, &mut control);
|
||||||
}
|
}
|
||||||
self.handle_event(Event::EventsCleared, &mut control);
|
self.handle_event(Event::EventsCleared, &mut control);
|
||||||
|
|
||||||
self.apply_control_flow(control);
|
self.apply_control_flow(control);
|
||||||
|
|
||||||
// If the event loop is closed, it has been closed this iteration and now the closing
|
// If the event loop is closed, it has been closed this iteration and now the closing
|
||||||
// event should be emitted
|
// event should be emitted
|
||||||
if self.closed() {
|
if self.closed() {
|
||||||
self.handle_event(Event::LoopDestroyed, &mut control);
|
self.handle_event(Event::LoopDestroyed, &mut control);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
|
||||||
self.0.events.borrow_mut().push_back(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle_event takes in events and either queues them or applies a callback
|
// handle_event takes in events and either queues them or applies a callback
|
||||||
//
|
//
|
||||||
|
@ -464,5 +465,13 @@ impl<T: 'static> EventLoopRunnerShared<T> {
|
||||||
None => false, // If the event loop is None, it has not been intialised yet, so it cannot be closed
|
None => false, // If the event loop is None, it has not been intialised yet, so it cannot be closed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the current control flow state
|
||||||
|
fn current_control_flow(&self) -> ControlFlow {
|
||||||
|
match *self.0.runner.borrow() {
|
||||||
|
Some(ref runner) => runner.control.to_control_flow(),
|
||||||
|
None => ControlFlow::Poll,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue