File tree Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,12 @@ pub fn prepare(identifier: &str) {
76
76
platform_impl:: prepare ( identifier)
77
77
}
78
78
79
+ /// TODO: Windows-only for now
80
+ #[ cfg( target_os = "windows" ) ]
81
+ pub fn destroy ( ) {
82
+ platform_impl:: destroy ( )
83
+ }
84
+
79
85
/// Helper to get current exe path
80
86
pub ( crate ) fn current_exe ( ) -> std:: io:: Result < PathBuf > {
81
87
let path = std:: env:: current_exe ( ) ?;
Original file line number Diff line number Diff line change @@ -51,3 +51,7 @@ pub fn prepare(identifier: &str) {
51
51
ID . set ( identifier. to_string ( ) )
52
52
. expect ( "prepare() called more than once with different identifiers." ) ;
53
53
}
54
+
55
+ pub fn destroy ( ) {
56
+ windows_single:: destroy ( ) ;
57
+ }
Original file line number Diff line number Diff line change @@ -76,25 +76,25 @@ pub fn init(f: Box<SingleInstanceCallback>) {
76
76
}
77
77
}
78
78
79
- // pub fn destroy() {
80
- // if let Some(hmutex) = MUTEX_HANDLE.get() {
81
- // unsafe {
82
- // ReleaseMutex(hmutex.0 as _);
83
- // CloseHandle(hmutex.0 as _);
84
- // }
85
- // }
86
- // if let Some(hwnd) = TARGET_WINDOW_HANDLE.get() {
87
- // unsafe { DestroyWindow(hwnd.0 as _) };
88
- // }
89
- // }
79
+ pub fn destroy ( ) {
80
+ if let Some ( hmutex) = MUTEX_HANDLE . get ( ) {
81
+ unsafe {
82
+ ReleaseMutex ( hmutex. 0 as _ ) ;
83
+ CloseHandle ( hmutex. 0 as _ ) ;
84
+ }
85
+ }
86
+ if let Some ( hwnd) = TARGET_WINDOW_HANDLE . get ( ) {
87
+ unsafe { DestroyWindow ( hwnd. 0 as _ ) } ;
88
+ }
89
+ }
90
90
91
91
unsafe extern "system" fn single_instance_window_proc (
92
92
hwnd : HWND ,
93
93
msg : u32 ,
94
94
wparam : WPARAM ,
95
95
lparam : LPARAM ,
96
96
) -> LRESULT {
97
- let data_ptr = GetWindowLongPtrW ( hwnd, GWL_USERDATA ) as * mut ( Box < SingleInstanceCallback > ) ;
97
+ let data_ptr = GetWindowLongPtrW ( hwnd, GWL_USERDATA ) as * mut Box < SingleInstanceCallback > ;
98
98
let callback = & mut * data_ptr;
99
99
100
100
match msg {
You can’t perform that action at this time.
0 commit comments