Commit: 4069016de893866c996d0979ab35e9f3c6aeb957
Author: Corbin Dunn
Date:   Tue Mar 9 21:38:47 2021 +0530
Branches: master
https://developer.blender.org/rB4069016de893866c996d0979ab35e9f3c6aeb957

macOS/Ghost: Simplify pasteboard and screen count code

Reviewed By: #platform_macos, sebbas, ankitm
Differential Revision: https://developer.blender.org/D10616

===================================================================

M       intern/ghost/intern/GHOST_SystemCocoa.mm

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm 
b/intern/ghost/intern/GHOST_SystemCocoa.mm
index baa2bcd47b6..9c28449a4e5 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -674,9 +674,8 @@ GHOST_TUns8 GHOST_SystemCocoa::getNumDisplays() const
   // Note that OS X supports monitor hot plug
   // We do not support multiple monitors at the moment
   @autoreleasepool {
-    GHOST_TUns8 count = [[NSScreen screens] count];
+    return NSScreen.screens.count;
   }
-  return count;
 }
 
 void GHOST_SystemCocoa::getMainDisplayDimensions(GHOST_TUns32 &width, 
GHOST_TUns32 &height) const
@@ -1945,18 +1944,6 @@ GHOST_TUns8 *GHOST_SystemCocoa::getClipboard(bool 
selection) const
 
     NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard];
 
-    if (pasteBoard == nil) {
-      return NULL;
-    }
-
-    NSArray *supportedTypes = [NSArray arrayWithObjects:NSStringPboardType, 
nil];
-
-    NSString *bestType = [[NSPasteboard generalPasteboard] 
availableTypeFromArray:supportedTypes];
-
-    if (bestType == nil) {
-      return NULL;
-    }
-
     NSString *textPasted = [pasteBoard stringForType:NSStringPboardType];
 
     if (textPasted == nil) {
@@ -1987,25 +1974,14 @@ GHOST_TUns8 *GHOST_SystemCocoa::getClipboard(bool 
selection) const
 
 void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const
 {
-  NSString *textToCopy;
-
   if (selection)
     return;  // for copying the selection, used on X11
 
   @autoreleasepool {
 
-    NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard];
-
-    if (pasteBoard == nil) {
-      return;
-    }
-
-    NSArray *supportedTypes = [NSArray arrayWithObject:NSStringPboardType];
-
-    [pasteBoard declareTypes:supportedTypes owner:nil];
-
-    textToCopy = [NSString stringWithCString:buffer 
encoding:NSUTF8StringEncoding];
-
+    NSPasteboard *pasteBoard = NSPasteboard.generalPasteboard;
+    [pasteBoard declareTypes:@[ NSStringPboardType ] owner:nil];
+    NSString *textToCopy = [NSString stringWithCString:buffer 
encoding:NSUTF8StringEncoding];
     [pasteBoard setString:textToCopy forType:NSStringPboardType];
   }
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to