Skip to content

Commit

Permalink
fix(core): insert to webview_id_map on tao window creation, closes #3883
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Apr 22, 2022
1 parent 7864d41 commit 320329a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-create-tao-window.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri": patch
"tauri-runtime-wry": patch
---

Fixes a panic when using the `create_tao_window` API.
6 changes: 6 additions & 0 deletions core/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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>>,
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 320329a

Please sign in to comment.