@@ -130,12 +130,6 @@ impl std::hash::Hash for SCShareableContent {
130130 }
131131}
132132
133- impl Clone for SCShareableContent {
134- fn clone ( & self ) -> Self {
135- unsafe { Self ( crate :: ffi:: sc_shareable_content_retain ( self . 0 ) ) }
136- }
137- }
138-
139133impl SCShareableContent {
140134 /// Create from raw pointer (used internally)
141135 ///
@@ -212,9 +206,7 @@ impl SCShareableContent {
212206
213207 for i in 0 ..count {
214208 let display_ptr = crate :: ffi:: sc_shareable_content_get_display_at ( self . 0 , i) ;
215- if !display_ptr. is_null ( ) {
216- displays. push ( SCDisplay :: from_ptr ( display_ptr) ) ;
217- }
209+ displays. extend ( SCDisplay :: from_retained_ptr ( display_ptr) ) ;
218210 }
219211
220212 displays
@@ -247,9 +239,7 @@ impl SCShareableContent {
247239
248240 for i in 0 ..count {
249241 let window_ptr = crate :: ffi:: sc_shareable_content_get_window_at ( self . 0 , i) ;
250- if !window_ptr. is_null ( ) {
251- windows. push ( SCWindow :: from_ptr ( window_ptr) ) ;
252- }
242+ windows. extend ( SCWindow :: from_retained_ptr ( window_ptr) ) ;
253243 }
254244
255245 windows
@@ -280,9 +270,7 @@ impl SCShareableContent {
280270
281271 for i in 0 ..count {
282272 let app_ptr = crate :: ffi:: sc_shareable_content_get_application_at ( self . 0 , i) ;
283- if !app_ptr. is_null ( ) {
284- apps. push ( SCRunningApplication :: from_ptr ( app_ptr) ) ;
285- }
273+ apps. extend ( SCRunningApplication :: from_retained_ptr ( app_ptr) ) ;
286274 }
287275
288276 apps
@@ -321,15 +309,11 @@ impl SCShareableContent {
321309 }
322310}
323311
324- impl Drop for SCShareableContent {
325- fn drop ( & mut self ) {
326- if !self . 0 . is_null ( ) {
327- unsafe {
328- crate :: ffi:: sc_shareable_content_release ( self . 0 ) ;
329- }
330- }
331- }
332- }
312+ crate :: utils:: retained:: sc_retained!(
313+ SCShareableContent ,
314+ retain = crate :: ffi:: sc_shareable_content_retain,
315+ release = crate :: ffi:: sc_shareable_content_release,
316+ ) ;
333317
334318impl fmt:: Debug for SCShareableContent {
335319 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -586,22 +570,11 @@ impl SCShareableContentInfo {
586570}
587571
588572#[ cfg( feature = "macos_14_0" ) ]
589- impl Drop for SCShareableContentInfo {
590- fn drop ( & mut self ) {
591- if !self . 0 . is_null ( ) {
592- unsafe {
593- crate :: ffi:: sc_shareable_content_info_release ( self . 0 ) ;
594- }
595- }
596- }
597- }
598-
599- #[ cfg( feature = "macos_14_0" ) ]
600- impl Clone for SCShareableContentInfo {
601- fn clone ( & self ) -> Self {
602- unsafe { Self ( crate :: ffi:: sc_shareable_content_info_retain ( self . 0 ) ) }
603- }
604- }
573+ crate :: utils:: retained:: sc_retained!(
574+ SCShareableContentInfo ,
575+ retain = crate :: ffi:: sc_shareable_content_info_retain,
576+ release = crate :: ffi:: sc_shareable_content_info_release,
577+ ) ;
605578
606579#[ cfg( feature = "macos_14_0" ) ]
607580impl fmt:: Debug for SCShareableContentInfo {
0 commit comments