diff mbox series

ui/cocoa.m: Suppress NSFileHandlingPanelOKButton depreciation warning

Message ID 20180529180813.2647-1-programmingkidx@gmail.com
State New
Headers show
Series ui/cocoa.m: Suppress NSFileHandlingPanelOKButton depreciation warning | expand

Commit Message

Programmingkid May 29, 2018, 6:08 p.m. UTC
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.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
---
 ui/cocoa.m | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Peter Maydell May 29, 2018, 6:11 p.m. UTC | #1
On 29 May 2018 at 19:08, John Arbuckle <programmingkidx@gmail.com> wrote:
> 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.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> ---
>  ui/cocoa.m | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 110b393..c9473f0 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -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
Programmingkid May 29, 2018, 6:12 p.m. UTC | #2
> On May 29, 2018, at 2:11 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> 
> On 29 May 2018 at 19:08, John Arbuckle <programmingkidx@gmail.com> wrote:
>> 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.
>> 
>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>> ---
>> ui/cocoa.m | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>> 
>> diff --git a/ui/cocoa.m b/ui/cocoa.m
>> index 110b393..c9473f0 100644
>> --- a/ui/cocoa.m
>> +++ b/ui/cocoa.m
>> @@ -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.

Sounds like a good idea.
Eric Blake May 29, 2018, 8:55 p.m. UTC | #3
On 05/29/2018 01:08 PM, John Arbuckle wrote:

In the subject: s/depreciation/deprecation/

> 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.
> 
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> ---
>   ui/cocoa.m | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 110b393..c9473f0 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -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();