mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-26 04:03:29 +03:00
fix(core): deadlock on window event handler
This commit is contained in:
parent
63ae30f187
commit
4866404f04
@ -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
|
if let Some(WindowHandle::Webview(webview)) = windows
|
||||||
.lock()
|
.lock()
|
||||||
.expect("poisoned webview collection")
|
.expect("poisoned webview collection")
|
||||||
.get(&id)
|
.get(&id)
|
||||||
.map(|w| &w.inner)
|
.map(|w| &w.inner)
|
||||||
{
|
{
|
||||||
match webview_message {
|
|
||||||
WebviewMessage::EvaluateScript(script) => {
|
|
||||||
if let Err(e) = webview.evaluate_script(&script) {
|
if let Err(e) = webview.evaluate_script(&script) {
|
||||||
eprintln!("{}", e);
|
eprintln!("{}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
WebviewMessage::Print => {
|
WebviewMessage::Print => {
|
||||||
|
if let Some(WindowHandle::Webview(webview)) = windows
|
||||||
|
.lock()
|
||||||
|
.expect("poisoned webview collection")
|
||||||
|
.get(&id)
|
||||||
|
.map(|w| &w.inner)
|
||||||
|
{
|
||||||
let _ = webview.print();
|
let _ = webview.print();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
WebviewMessage::WebviewEvent(event) => {
|
WebviewMessage::WebviewEvent(event) => {
|
||||||
if let Some(event) = WindowEventWrapper::from(&event).0 {
|
if let Some(event) = WindowEventWrapper::from(&event).0 {
|
||||||
for handler in window_event_listeners
|
for handler in window_event_listeners
|
||||||
@ -2055,9 +2062,7 @@ fn handle_user_message(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
Message::CreateWebview(handler, sender) => {
|
Message::CreateWebview(handler, sender) => {
|
||||||
if let Some(event_loop) = event_loop {
|
if let Some(event_loop) = event_loop {
|
||||||
match handler(event_loop, web_context) {
|
match handler(event_loop, web_context) {
|
||||||
|
Loading…
Reference in New Issue
Block a user