Browse Source

REVIEW: fix possible -Wdeprecated-declarations warnings

deepak1556 6 years ago
parent
commit
9755288527

+ 8 - 6
atom/browser/browser_mac.mm

@@ -231,9 +231,10 @@ LSSharedFileListItemRef GetLoginItemForApp() {
   for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
     LSSharedFileListItemRef item =
         reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
-    CFURLRef item_url_ref = NULL;
-    if (LSSharedFileListItemResolve(item, 0, &item_url_ref, NULL) == noErr &&
-        item_url_ref) {
+    base::ScopedCFTypeRef<CFErrorRef> error;
+    CFURLRef item_url_ref =
+        LSSharedFileListItemCopyResolvedURL(item, 0, error.InitializeInto());
+    if (!error && item_url_ref) {
       base::ScopedCFTypeRef<CFURLRef> item_url(item_url_ref);
       if (CFEqual(item_url, url)) {
         CFRetain(item);
@@ -264,9 +265,10 @@ void RemoveFromLoginItems() {
     for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
       LSSharedFileListItemRef item =
           reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
-      CFURLRef url_ref = NULL;
-      if (LSSharedFileListItemResolve(item, 0, &url_ref, NULL) == noErr &&
-          item) {
+      base::ScopedCFTypeRef<CFErrorRef> error;
+      CFURLRef url_ref =
+          LSSharedFileListItemCopyResolvedURL(item, 0, error.InitializeInto());
+      if (!error && url_ref) {
         base::ScopedCFTypeRef<CFURLRef> url(url_ref);
         if ([[base::mac::CFToNSCast(url.get()) path]
                 hasPrefix:[[NSBundle mainBundle] bundlePath]])

+ 5 - 14
atom/browser/ui/cocoa/atom_bundle_mover.mm

@@ -167,20 +167,11 @@ NSString* AtomBundleMover::ContainingDiskImageDevice(NSString* bundlePath) {
   NSData* data =
       [[[hdiutil standardOutput] fileHandleForReading] readDataToEndOfFile];
 
-  NSDictionary* info = nil;
-  if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
-    info = [NSPropertyListSerialization
-        propertyListWithData:data
-                     options:NSPropertyListImmutable
-                      format:NULL
-                       error:NULL];
-  } else {
-    info = [NSPropertyListSerialization
-        propertyListFromData:data
-            mutabilityOption:NSPropertyListImmutable
-                      format:NULL
-            errorDescription:NULL];
-  }
+  NSDictionary* info =
+      [NSPropertyListSerialization propertyListWithData:data
+                                                options:NSPropertyListImmutable
+                                                 format:NULL
+                                                  error:NULL];
 
   if (![info isKindOfClass:[NSDictionary class]])
     return nil;

+ 6 - 0
atom/browser/ui/message_box_mac.mm

@@ -157,10 +157,13 @@ int ShowMessageBox(NativeWindow* parent_window,
           callEndModal:true];
 
   NSWindow* window = parent_window->GetNativeWindow().GetNativeNSWindow();
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
   [alert beginSheetModalForWindow:window
                     modalDelegate:delegate
                    didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
                       contextInfo:nil];
+#pragma clang diagnostic pop
 
   [NSApp runModalForWindow:window];
   return ret_code;
@@ -196,11 +199,14 @@ void ShowMessageBox(NativeWindow* parent_window,
     NSWindow* window =
         parent_window ? parent_window->GetNativeWindow().GetNativeNSWindow()
                       : nil;
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
     [alert
         beginSheetModalForWindow:window
                    modalDelegate:delegate
                   didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
                      contextInfo:nil];
+#pragma clang diagnostic pop
   }
 }
 

+ 3 - 0
atom/common/platform_util_mac.mm

@@ -141,8 +141,11 @@ void Beep() {
 
 bool GetLoginItemEnabled() {
   BOOL enabled = NO;
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
   // SMJobCopyDictionary does not work in sandbox (see rdar://13626319)
   CFArrayRef jobs = SMCopyAllJobDictionaries(kSMDomainUserLaunchd);
+#pragma clang diagnostic pop
   NSArray* jobs_ = CFBridgingRelease(jobs);
   NSString* identifier = GetLoginHelperBundleIdentifier();
   if (jobs_ && [jobs_ count] > 0) {