Skip to content

fix(core): macos #5122 app.runtime panic in app.set_activation_policy#8713

Merged
lucasfernog merged 3 commits into
tauri-apps:devfrom
washanhanzi:fix/set-activation-policy-panic
Feb 2, 2024
Merged

fix(core): macos #5122 app.runtime panic in app.set_activation_policy#8713
lucasfernog merged 3 commits into
tauri-apps:devfrom
washanhanzi:fix/set-activation-policy-panic

Conversation

@washanhanzi

Copy link
Copy Markdown
Contributor
  1. fix [bug] set_actionvation_policy() breaks window.show() #5122
  2. the problem:
pub fn run() {
    let mut app = tauri::Builder::default()
        .setup(|app| {
            // c
            app.set_activation_policy(tauri::ActivationPolicy::Accessory);
            Ok(())
        })
        .build(tauri::tauri_build_context!())
        .unwrap();
    // a
    app.set_activation_policy(tauri::ActivationPolicy::Regular);
    // b
    app.run(move |_app_handle, _event| {})
}

a: this line runs first
b: app.run will take the app.runtime as in

self.runtime.take().unwrap().run(move |event| match event {

c: the set_activation_policy will try to get app.runtime and unwrap, but now, the app.runtime is None and the program panic.

I add an if let to set_activation_policy. This will cause c ignored silently, maybe we need a better approach.

And it seems the bug is not related to window.show() in the original issue, whether before or after the multi web view refactor c77b403.

@washanhanzi washanhanzi requested a review from a team as a code owner January 31, 2024 11:12
@washanhanzi washanhanzi changed the title fix(macos): #5122 app.runtime panic in app.set_activation_policy fix(core): macos #5122 app.runtime panic in app.set_activation_policy Jan 31, 2024

@lucasfernog lucasfernog left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed a change to make it work when the app is running too. Thank you!

@lucasfernog lucasfernog merged commit 95da1a2 into tauri-apps:dev Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] set_actionvation_policy() breaks window.show()

2 participants