Skip to content

Commit

Permalink
fix(single-instance): Fix compile errors after windows-sys 0.59 update,
Browse files Browse the repository at this point in the history
fixes #1730
  • Loading branch information
FabianLars committed Sep 4, 2024
1 parent 104f482 commit 5c249a1
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions plugins/single-instance/src/platform_impl/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn init<R: Runtime>(f: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
unsafe {
let hwnd = FindWindowW(class_name.as_ptr(), window_name.as_ptr());

if hwnd != 0 {
if !hwnd.is_null() {
let data = format!(
"{}|{}\0",
std::env::current_dir()
Expand All @@ -69,7 +69,7 @@ pub fn init<R: Runtime>(f: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
}
}
} else {
app.manage(MutexHandle(hmutex));
app.manage(MutexHandle(hmutex as _));

let hwnd = create_event_target_window::<R>(&class_name, &window_name);
unsafe {
Expand All @@ -80,7 +80,7 @@ pub fn init<R: Runtime>(f: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
)
};

app.manage(TargetWindowHandle(hwnd));
app.manage(TargetWindowHandle(hwnd as _));
}

Ok(())
Expand All @@ -96,12 +96,12 @@ pub fn init<R: Runtime>(f: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
pub fn destroy<R: Runtime, M: Manager<R>>(manager: &M) {
if let Some(hmutex) = manager.try_state::<MutexHandle>() {
unsafe {
ReleaseMutex(hmutex.0);
CloseHandle(hmutex.0);
ReleaseMutex(hmutex.0 as _);
CloseHandle(hmutex.0 as _);
}
}
if let Some(hwnd) = manager.try_state::<TargetWindowHandle>() {
unsafe { DestroyWindow(hwnd.0) };
unsafe { DestroyWindow(hwnd.0 as _) };
}
}

Expand Down Expand Up @@ -145,12 +145,12 @@ fn create_event_target_window<R: Runtime>(class_name: &[u16], window_name: &[u16
cbClsExtra: 0,
cbWndExtra: 0,
hInstance: GetModuleHandleW(std::ptr::null()),
hIcon: 0,
hCursor: 0,
hbrBackground: 0,
hIcon: std::ptr::null_mut(),
hCursor: std::ptr::null_mut(),
hbrBackground: std::ptr::null_mut(),
lpszMenuName: std::ptr::null(),
lpszClassName: class_name.as_ptr(),
hIconSm: 0,
hIconSm: std::ptr::null_mut(),
};

RegisterClassExW(&class);
Expand All @@ -174,8 +174,8 @@ fn create_event_target_window<R: Runtime>(class_name: &[u16], window_name: &[u16
0,
0,
0,
0,
0,
std::ptr::null_mut(),
std::ptr::null_mut(),
GetModuleHandleW(std::ptr::null()),
std::ptr::null(),
);
Expand Down

0 comments on commit 5c249a1

Please sign in to comment.