Skip to content

[bug] CoInitializeEx with different thread mode causes panic #4580

Description

@oumad

Describe the bug

When running CoInitializeEx with a different thread mode than the one used by tao (for ex : COINIT_MULTITHREADED), the application panics,

Reproduction

Just call CoInitializeEx with COINIT_MULTITHREADED before everything as mentioned in the docs :
https://docs.rs/tao/latest/x86_64-pc-windows-msvc/tao/platform/windows/trait.WindowBuilderExtWindows.html#tymethod.with_drag_and_drop

Code example :

fn main() {
  unsafe{
    match CoInitializeEx(std::ptr::null(), COINIT_MULTITHREADED){
      Err(e) => {
          println!("Couldn't CoInitializeEx: {}", e);
        }
        Ok(_) => println!("CoInitializeEx done"),
    };
  }
  tauri::Builder::default()
    .invoke_handler(tauri::generate_handler![get_directory,get_selected_files,say_hello])
    .run(tauri::generate_context!())
    .expect("error while running tauri application");
}

Expected behavior

No response

Platform and versions

Windows 10
tauri = { version = "1.0.2", features = ["api-all"] }

Stack trace

CoInitializeEx done
thread 'main' panicked at 'OleInitialize failed! Result was: `RPC_E_CHANGED_MODE`. Make sure other crates are not using multithreaded COM library on the same thread or disable drag and drop support.', C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\tao-0.12.1\src\platform_impl\windows\window.rs:100:45
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error Command failed with exit code 101.

Additional context

Normally this should not happen if fileDropEnabled is set to false, so if I understood right, tao's function
https://docs.rs/tao/latest/x86_64-pc-windows-msvc/tao/platform/windows/trait.WindowBuilderExtWindows.html#tymethod.with_drag_and_drop
Should take into consideration the given fileDropEnabled value.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions