Skip to content

Commit

Permalink
Upgrade windows crate (#96)
Browse files Browse the repository at this point in the history
* Upgrade windows crate to 0.43

* Fixes for 0.40 API changes
  • Loading branch information
mauvealerts authored Dec 2, 2022
1 parent 5b59f47 commit 4644229
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/backend/win_cid/file_dialog/dialog_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}
}
}
Expand Down Expand Up @@ -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);
Expand All @@ -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))
}
Expand Down
4 changes: 1 addition & 3 deletions src/backend/win_cid/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: FnOnce() -> T>(f: F) -> Result<T> {
unsafe {
CoInitializeEx(
ptr::null_mut(),
None,
COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE,
)?
};
Expand Down

0 comments on commit 4644229

Please sign in to comment.