fix(core): deadlock on window event handler

This commit is contained in:
Lucas Nogueira 2021-09-26 10:01:03 -03:00
parent 63ae30f187
commit 4866404f04

View File

@ -2024,22 +2024,29 @@ fn handle_user_message(
}
}
}
Message::Webview(id, webview_message) => {
Message::Webview(id, webview_message) => match webview_message {
WebviewMessage::EvaluateScript(script) => {
if let Some(WindowHandle::Webview(webview)) = windows
.lock()
.expect("poisoned webview collection")
.get(&id)
.map(|w| &w.inner)
{
match webview_message {
WebviewMessage::EvaluateScript(script) => {
if let Err(e) = webview.evaluate_script(&script) {
eprintln!("{}", e);
}
}
}
WebviewMessage::Print => {
if let Some(WindowHandle::Webview(webview)) = windows
.lock()
.expect("poisoned webview collection")
.get(&id)
.map(|w| &w.inner)
{
let _ = webview.print();
}
}
WebviewMessage::WebviewEvent(event) => {
if let Some(event) = WindowEventWrapper::from(&event).0 {
for handler in window_event_listeners
@ -2055,9 +2062,7 @@ fn handle_user_message(
}
}
}
}
}
}
},
Message::CreateWebview(handler, sender) => {
if let Some(event_loop) = event_loop {
match handler(event_loop, web_context) {