fix(core): insert to webview_id_map on tao window creation, closes #3883 (#3932)

This commit is contained in:
Lucas Fernandes Nogueira 2022-04-21 20:34:22 -07:00 committed by GitHub
parent 7864d41de8
commit 320329a9a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
"tauri": patch
"tauri-runtime-wry": patch
---
Fixes a panic when using the `create_tao_window` API.

View File

@ -154,6 +154,7 @@ fn send_user_message<T: UserEvent>(context: &Context<T>, message: Message<T>) ->
&context.main_thread.window_target,
message,
UserMessageContext {
webview_id_map: context.webview_id_map.clone(),
window_event_listeners: &context.window_event_listeners,
global_shortcut_manager: context.main_thread.global_shortcut_manager.clone(),
clipboard_manager: context.main_thread.clipboard_manager.clone(),
@ -2105,6 +2106,7 @@ pub struct EventLoopIterationContext<'a, T: UserEvent> {
}
struct UserMessageContext<'a> {
webview_id_map: WebviewIdStore,
window_event_listeners: &'a WindowEventListeners,
global_shortcut_manager: Arc<Mutex<WryShortcutManager>>,
clipboard_manager: Arc<Mutex<Clipboard>>,
@ -2121,6 +2123,7 @@ fn handle_user_message<T: UserEvent>(
web_context: &WebContextStore,
) -> RunIteration {
let UserMessageContext {
webview_id_map,
window_event_listeners,
menu_event_listeners,
global_shortcut_manager,
@ -2368,6 +2371,8 @@ fn handle_user_message<T: UserEvent>(
.unwrap()
.insert(window_id, WindowMenuEventListeners::default());
webview_id_map.insert(window.id(), window_id);
let w = Arc::new(window);
windows.lock().expect("poisoned webview collection").insert(
@ -2698,6 +2703,7 @@ fn handle_event_loop<T: UserEvent>(
event_loop,
message,
UserMessageContext {
webview_id_map,
window_event_listeners,
global_shortcut_manager,
clipboard_manager,