[Bf-blender-cvs] [593eab66b5c] master: Cleanup: remove use of deprecated macOS API

Brecht Van Lommel noreply at git.blender.org
Sun Jun 2 13:07:02 CEST 2019


Commit: 593eab66b5caa02dcd632eab909cccc137bc2fcd
Author: Brecht Van Lommel
Date:   Sat Jun 1 19:56:52 2019 +0200
Branches: master
https://developer.blender.org/rB593eab66b5caa02dcd632eab909cccc137bc2fcd

Cleanup: remove use of deprecated macOS API

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

M	intern/ghost/intern/GHOST_SystemCocoa.mm

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

diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index eb54ed20fe1..c80424b279b 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1341,7 +1341,7 @@ void GHOST_SystemCocoa::handleQuitRequest()
 bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
 {
   NSString *filepath = (NSString *)filepathStr;
-  int confirmOpen = NSAlertAlternateReturn;
+  bool confirmOpen = true;
   NSArray *windowsList;
   char *temp_buff;
   size_t filenameTextSize;
@@ -1358,12 +1358,17 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
 
   // Check open windows if some changes are not saved
   if (m_windowManager->getAnyModifiedState()) {
-    confirmOpen = NSRunAlertPanel(
-        [NSString stringWithFormat:@"Opening %@", [filepath lastPathComponent]],
-        @"Current document has not been saved.\nDo you really want to proceed?",
-        @"Cancel",
-        @"Open",
-        nil);
+    @autoreleasepool {
+      NSAlert *alert = [[NSAlert alloc] init];
+      NSString *title = [NSString stringWithFormat:@"Opening %@", [filepath lastPathComponent]];
+      NSString *text = @"Current document has not been saved.\nDo you really want to proceed?";
+      [alert addButtonWithTitle:@"Open"];
+      [alert addButtonWithTitle:@"Cancel"];
+      [alert setMessageText:title];
+      [alert setInformativeText:text];
+      [alert setAlertStyle:NSAlertStyleInformational];
+      confirmOpen = [alert runModal] == NSAlertFirstButtonReturn;
+    }
   }
 
   // Give back focus to the blender window
@@ -1372,7 +1377,7 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
     [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
   }
 
-  if (confirmOpen == NSAlertAlternateReturn) {
+  if (confirmOpen) {
     filenameTextSize = [filepath lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
 
     temp_buff = (char *)malloc(filenameTextSize + 1);



More information about the Bf-blender-cvs mailing list