From 4644229c38a21e25e9de90228c36fd0164858ce4 Mon Sep 17 00:00:00 2001 From: Mauve Date: Thu, 1 Dec 2022 19:58:08 -0500 Subject: [PATCH] Upgrade windows crate (#96) * Upgrade windows crate to 0.43 * Fixes for 0.40 API changes --- Cargo.toml | 2 +- src/backend/win_cid/file_dialog/dialog_ffi.rs | 6 +++--- src/backend/win_cid/utils.rs | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6d19666..c75f6bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ block = "0.1.6" objc-foundation = "0.1.1" [target.'cfg(target_os = "windows")'.dependencies] -windows = { version = "0.37", features = [ +windows = { version = "0.43", features = [ "Win32_Foundation", "Win32_System_Com", "Win32_UI_Shell_Common", diff --git a/src/backend/win_cid/file_dialog/dialog_ffi.rs b/src/backend/win_cid/file_dialog/dialog_ffi.rs index 421961a..5a87ed9 100644 --- a/src/backend/win_cid/file_dialog/dialog_ffi.rs +++ b/src/backend/win_cid/file_dialog/dialog_ffi.rs @@ -140,7 +140,7 @@ impl IDialog { if let Some(item) = item { // For some reason SetDefaultFolder(), does not guarantees default path, so we use SetFolder - self.0.as_dialog().SetFolder(item)?; + self.0.as_dialog().SetFolder(&item)?; } } } @@ -194,7 +194,7 @@ impl IDialog { let filename = read_to_string(display_name); - CoTaskMemFree(display_name.0 as _); + CoTaskMemFree(Some(display_name.0 as _)); let path = PathBuf::from(filename); paths.push(path); @@ -210,7 +210,7 @@ impl IDialog { let display_name = res_item.GetDisplayName(SIGDN_FILESYSPATH)?; let filename = read_to_string(display_name); - CoTaskMemFree(display_name.0 as _); + CoTaskMemFree(Some(display_name.0 as _)); Ok(PathBuf::from(filename)) } diff --git a/src/backend/win_cid/utils.rs b/src/backend/win_cid/utils.rs index 5ed91e1..d31b7cd 100644 --- a/src/backend/win_cid/utils.rs +++ b/src/backend/win_cid/utils.rs @@ -4,13 +4,11 @@ use windows::Win32::System::Com::{ CoInitializeEx, CoUninitialize, COINIT_APARTMENTTHREADED, COINIT_DISABLE_OLE1DDE, }; -use std::ptr; - /// Makes sure that COM lib is initialized long enought pub fn init_com T>(f: F) -> Result { unsafe { CoInitializeEx( - ptr::null_mut(), + None, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE, )? };