@@ -102,8 +102,8 @@ pub(crate) fn clear_recent_documents<R: Runtime>(_app: AppHandle<R>) -> Result<(
102102
103103 let dests: IApplicationDestinations =
104104 CoCreateInstance ( & ApplicationDestinations , None , CLSCTX_INPROC_SERVER ) ?;
105- let _ = dests. SetAppID ( PCWSTR :: from_raw ( app_id_hstring. as_ptr ( ) ) ) ;
106- let _ = dests. RemoveAllDestinations ( ) ;
105+ dests. SetAppID ( & app_id_hstring) ? ;
106+ dests. RemoveAllDestinations ( ) ? ;
107107 }
108108
109109 #[ cfg( target_os = "macos" ) ]
@@ -132,25 +132,23 @@ pub(crate) fn get_recent_documents<R: Runtime>(_app: AppHandle<R>) -> Result<Vec
132132
133133 let app_id = & _app. config ( ) . identifier ;
134134 let app_id_hstring = HSTRING :: from ( app_id) ;
135- let app_id_pcwstr = PCWSTR :: from_raw ( app_id_hstring. as_ptr ( ) ) ;
136135
137136 let doc_lists: IApplicationDocumentLists =
138137 CoCreateInstance ( & ApplicationDocumentLists , None , CLSCTX_INPROC_SERVER ) ?;
139- let _ = doc_lists. SetAppID ( app_id_pcwstr) ;
140- if let Ok ( obj_array) = doc_lists. GetList :: < IObjectArray > ( ADLT_RECENT , 30 ) {
141- let count = obj_array. GetCount ( ) . unwrap_or ( 0 ) ;
142-
143- for i in 0 ..count {
144- if let Ok ( shell_item) = obj_array. GetAt :: < IShellItem > ( i) {
145- if let Ok ( name_pwstr) = shell_item. GetDisplayName ( SIGDN_FILESYSPATH ) {
146- if let Ok ( path) = name_pwstr. to_string ( ) {
147- if !path. is_empty ( ) {
148- recent_docs. push ( path) ;
149- }
138+ doc_lists. SetAppID ( & app_id_hstring) ?;
139+ let obj_array: IObjectArray = doc_lists. GetList ( ADLT_RECENT , 30 ) ?;
140+ let count = obj_array. GetCount ( ) ?;
141+
142+ for i in 0 ..count {
143+ if let Ok ( shell_item) = obj_array. GetAt :: < IShellItem > ( i) {
144+ if let Ok ( name_pwstr) = shell_item. GetDisplayName ( SIGDN_FILESYSPATH ) {
145+ if let Ok ( path) = name_pwstr. to_string ( ) {
146+ if !path. is_empty ( ) {
147+ recent_docs. push ( path) ;
150148 }
151-
152- CoTaskMemFree ( Some ( name_pwstr. as_ptr ( ) as * const core:: ffi:: c_void ) ) ;
153149 }
150+
151+ CoTaskMemFree ( Some ( name_pwstr. as_ptr ( ) as * const core:: ffi:: c_void ) ) ;
154152 }
155153 }
156154 }
0 commit comments