Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: process didn't exit successfully #11

Merged
merged 4 commits into from Mar 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/lib.rs
@@ -1,5 +1,6 @@
use std::{
ffi::OsString,
mem::ManuallyDrop,
os::windows::prelude::{OsStrExt, OsStringExt},
path::{Path, PathBuf},
};
Expand Down Expand Up @@ -51,7 +52,7 @@ pub struct Monitor {

#[derive(Debug)]
pub struct DesktopWallpaper {
interface: IDesktopWallpaper,
interface: ManuallyDrop<IDesktopWallpaper>,
}

impl DesktopWallpaper {
Expand All @@ -61,7 +62,9 @@ impl DesktopWallpaper {
CoCreateInstance(&DesktopWallpaper, None, CLSCTX_LOCAL_SERVER)?
};

Ok(Self { interface })
Ok(Self {
interface: ManuallyDrop::new(interface),
})
}

pub fn get_monitors(&self) -> Result<Vec<Monitor>> {
Expand Down Expand Up @@ -138,6 +141,7 @@ impl DesktopWallpaper {
impl Drop for DesktopWallpaper {
fn drop(&mut self) {
unsafe {
ManuallyDrop::drop(&mut self.interface);
CoFreeUnusedLibraries();
CoUninitialize();
}
Expand Down