tauri icon indicating copy to clipboard operation
tauri copied to clipboard

Updating menu_handle title from within on_menu_event causes death spiral

Open nanodeath opened this issue 3 years ago • 3 comments

I have the following code in my Tauri application:

tauri::Builder::default()
    .menu(menu)
    .on_menu_event(move |event| {
        match event.menu_item_id() {
            "alwaysontop" => {
                let _ = event.window().set_always_on_top(true);
                let _ = event.window().menu_handle().get_item(event.menu_item_id()).set_title("test");
            }

and the last let statement seems to throw my application into a Not Responding state.

Interestingly, the Webview part of the app continues to load successfully.

The end goal is to have a kind of "checkbox" menu item, where I insert a ✔️ into the menu item depending on the current "always on top" state.

Tauri 1.1.0, Windows 10.

nanodeath avatar Sep 21 '22 00:09 nanodeath

can you try with #5245 there was a deadlock I fixed.

in src-tauri/Cargo.toml change tauri-build and tauri deps to:

[build-dependencies]
tauri-build = { git = "https://github.com/tauri-apps/tauri", branch = "fix-tray-cleanup" }

[dependencies]
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "fix-tray-cleanup" }

after that run cargo update inside src-tauri and test the changes

amrbashir avatar Sep 21 '22 11:09 amrbashir

Hey @amrbashir. No change unfortunately.

nanodeath avatar Sep 21 '22 14:09 nanodeath

try with https://github.com/tauri-apps/tauri/pull/5257 instead

[build-dependencies]
tauri-build = { git = "https://github.com/tauri-apps/tauri", branch = "menu-deadlock" }

[dependencies]
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "menu-deadlock" }

don't forget to run cargo update in src-tauri

amrbashir avatar Sep 21 '22 16:09 amrbashir

@amrbashir I can confirm your menu-deadlock branch fixes the problem 🎉

nanodeath avatar Sep 23 '22 14:09 nanodeath