Skip to contentSkip to conversation

ui/cocoa.m: Suppress NSFileHandlingPanelOKButton depreciation warning

PATCH In review John Arbuckle 3 participants 4 messages May 29, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui/cocoa.m: Suppress NSFileHandlingPanelOKButton depreciation warning

OSX 10.13 deprecates the NSFileHandlingPanelOKButton constant, and would rather you use NSModalResponseOK, which was introduced in OS 10.9. Use the recommended new constant name, with a backward compatibility define if we're building on an older OSX.

---
 ui/cocoa.m | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
ui/cocoa.m +8 -1
index 110b393..c9473f0 100644
@@ -79,6 +79,13 @@
 #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
 #define NSWindowStyleMaskTitled         NSTitledWindowMask
 #endif
+/* 10.13 deprecates NSFileHandlingPanelOKButton in favor of
+ * NSModalResponseOK, which was introduced in 10.9. Define
+ * it for older versions.
+ */
+#if !defined MAC_OS_X_VERSION_10_9 || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
+#define NSModalResponseOK NSFileHandlingPanelOKButton
+#endif
 
 //#define DEBUG
 
@@ -1218,7 +1225,7 @@ QemuCocoaView *cocoaView;
     [openPanel setCanChooseFiles: YES];
     [openPanel setAllowsMultipleSelection: NO];
     [openPanel setAllowedFileTypes: supportedImageFileTypes];
-    if([openPanel runModal] == NSFileHandlingPanelOKButton) {
+    if([openPanel runModal] == NSModalResponseOK) {
         NSString * file = [[[openPanel URLs] objectAtIndex: 0] path];
         if(file == nil) {
             NSBeep();
Signature · 1 line
2.10.2
#1 lore raw
Quoted 15 lines · John Arbuckle

OSX 10.13 deprecates the NSFileHandlingPanelOKButton constant, and would rather you use NSModalResponseOK, which was introduced in OS 10.9. Use the recommended new constant name, with a backward compatibility define if we're building on an older OSX.

---
 ui/cocoa.m | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
ui/cocoa.m +0 -0
index 110b393..c9473f0 100644

ui/cocoa.m line 88

Quoted 10 lines
ui/cocoa.m +7 -0
@@ -79,6 +79,13 @@
 #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
 #define NSWindowStyleMaskTitled         NSTitledWindowMask
 #endif
+/* 10.13 deprecates NSFileHandlingPanelOKButton in favor of
+ * NSModalResponseOK, which was introduced in 10.9. Define
+ * it for older versions.
+ */
+#if !defined MAC_OS_X_VERSION_10_9 || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
+#define NSModalResponseOK NSFileHandlingPanelOKButton
+#endif

We should just define MAC_OS_X_VERSION_10_9 if it's not defined, the same way we do for the 10_5/10_6/10_10/10_12 constants. I'll respin my patch.

thanks
-- PMM

#2 lore raw
Quoted 25 lines · Peter Maydell
Quoted 21 lines · John Arbuckle

OSX 10.13 deprecates the NSFileHandlingPanelOKButton constant, and would rather you use NSModalResponseOK, which was introduced in OS 10.9. Use the recommended new constant name, with a backward compatibility define if we're building on an older OSX.

---
ui/cocoa.m | 9 ++++++++-

1 file changed, 8 insertions(+), 1 deletion(-)
ui/cocoa.m +3 -0
index 110b393..c9473f0 100644
@@ -79,6 +79,13 @@
 #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
 #define NSWindowStyleMaskTitled         NSTitledWindowMask
 #endif
+/* 10.13 deprecates NSFileHandlingPanelOKButton in favor of
+ * NSModalResponseOK, which was introduced in 10.9. Define
+ * it for older versions.
Quoted 8 lines

ui/cocoa.m line 88

Quoted 4 lines
ui/cocoa.m +4 -0
+ */
+#if !defined MAC_OS_X_VERSION_10_9 || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
+#define NSModalResponseOK NSFileHandlingPanelOKButton
+#endif

We should just define MAC_OS_X_VERSION_10_9 if it's not defined, the same way we do for the 10_5/10_6/10_10/10_12 constants. I'll respin my patch.

Sounds like a good idea.

#3 lore raw
In reply to John Arbuckle

On 05/29/2018 01:08 PM, John Arbuckle wrote:

In the subject: s/depreciation/deprecation/

Quoted 9 lines

OSX 10.13 deprecates the NSFileHandlingPanelOKButton constant, and would rather you use NSModalResponseOK, which was introduced in OS 10.9. Use the recommended new constant name, with a backward compatibility define if we're building on an older OSX.

---
  ui/cocoa.m | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org