From bdeaeaf36832d07ab4632a6e6a3803f677bdc280 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 24 Jun 2019 15:05:17 +0100 Subject: [PATCH] macOS: Fixed some deprecation warnings and silenced some others for the time being --- .../native/juce_mac_CoreAudio.cpp | 30 +++++-------------- .../format_types/juce_VST3Headers.h | 1 + .../native/juce_BasicNativeHeaders.h | 8 +++++ .../juce_dsp/native/juce_sse_SIMDNativeOps.h | 4 +-- .../native/juce_mac_CoreGraphicsContext.mm | 6 ++-- .../native/juce_ios_UIViewComponentPeer.mm | 2 +- .../native/juce_mac_NSViewComponentPeer.mm | 21 +++++++------ .../native/juce_mac_Windowing.mm | 10 +++---- .../native/juce_mac_SystemTrayIcon.cpp | 7 +++-- .../native/juce_mac_WebBrowserComponent.mm | 11 +++++++ modules/juce_opengl/juce_opengl.h | 12 ++++++-- modules/juce_opengl/native/juce_OpenGL_osx.h | 19 ++++++++++++ .../juce_video/native/juce_mac_CameraDevice.h | 11 +++++++ 13 files changed, 93 insertions(+), 49 deletions(-) diff --git a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp index d36421e43b..8f1004e010 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp @@ -32,14 +32,6 @@ namespace juce #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnonnull" // aovid some spurious 10.11 SDK warnings - - // The AudioHardwareService stuff was deprecated in 10.11 but there's no replacement yet, - // so we'll have to silence the warnings here and revisit it in a future OS version.. - #if ((defined (MAC_OS_X_VERSION_10_13) && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_13) \ - || (defined (MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_12) \ - || (defined (MAC_OS_X_VERSION_10_11) && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_11)) - #pragma clang diagnostic ignored "-Wdeprecated-declarations" - #endif #endif //============================================================================== @@ -52,11 +44,10 @@ struct SystemVol addr.mElement = kAudioObjectPropertyElementMaster; addr.mSelector = kAudioHardwarePropertyDefaultOutputDevice; - if (AudioHardwareServiceHasProperty (kAudioObjectSystemObject, &addr)) + if (AudioObjectHasProperty (kAudioObjectSystemObject, &addr)) { UInt32 deviceIDSize = sizeof (outputDeviceID); - OSStatus status = AudioHardwareServiceGetPropertyData (kAudioObjectSystemObject, &addr, 0, - nullptr, &deviceIDSize, &outputDeviceID); + OSStatus status = AudioObjectGetPropertyData (kAudioObjectSystemObject, &addr, 0, nullptr, &deviceIDSize, &outputDeviceID); if (status == noErr) { @@ -64,7 +55,7 @@ struct SystemVol addr.mSelector = selector; addr.mScope = kAudioDevicePropertyScopeOutput; - if (! AudioHardwareServiceHasProperty (outputDeviceID, &addr)) + if (! AudioObjectHasProperty (outputDeviceID, &addr)) outputDeviceID = kAudioObjectUnknown; } } @@ -77,8 +68,7 @@ struct SystemVol if (outputDeviceID != kAudioObjectUnknown) { UInt32 size = sizeof (gain); - AudioHardwareServiceGetPropertyData (outputDeviceID, &addr, - 0, nullptr, &size, &gain); + AudioObjectGetPropertyData (outputDeviceID, &addr, 0, nullptr, &size, &gain); } return (float) gain; @@ -91,8 +81,7 @@ struct SystemVol Float32 newVolume = gain; UInt32 size = sizeof (newVolume); - return AudioHardwareServiceSetPropertyData (outputDeviceID, &addr, 0, nullptr, - size, &newVolume) == noErr; + return AudioObjectSetPropertyData (outputDeviceID, &addr, 0, nullptr, size, &newVolume) == noErr; } return false; @@ -105,8 +94,7 @@ struct SystemVol if (outputDeviceID != kAudioObjectUnknown) { UInt32 size = sizeof (muted); - AudioHardwareServiceGetPropertyData (outputDeviceID, &addr, - 0, nullptr, &size, &muted); + AudioObjectGetPropertyData (outputDeviceID, &addr, 0, nullptr, &size, &muted); } return muted != 0; @@ -119,8 +107,7 @@ struct SystemVol UInt32 newMute = mute ? 1 : 0; UInt32 size = sizeof (newMute); - return AudioHardwareServiceSetPropertyData (outputDeviceID, &addr, 0, nullptr, - size, &newMute) == noErr; + return AudioObjectSetPropertyData (outputDeviceID, &addr, 0, nullptr, size, &newMute) == noErr; } return false; @@ -133,8 +120,7 @@ private: bool canSetVolume() const noexcept { Boolean isSettable = NO; - return AudioHardwareServiceIsPropertySettable (outputDeviceID, &addr, &isSettable) == noErr - && isSettable; + return AudioObjectIsPropertySettable (outputDeviceID, &addr, &isSettable) == noErr && isSettable; } }; diff --git a/modules/juce_audio_processors/format_types/juce_VST3Headers.h b/modules/juce_audio_processors/format_types/juce_VST3Headers.h index 13a22cf3cb..3ab1ca2b18 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3Headers.h +++ b/modules/juce_audio_processors/format_types/juce_VST3Headers.h @@ -47,6 +47,7 @@ #pragma clang diagnostic ignored "-Wdeprecated-declarations" #pragma clang diagnostic ignored "-Wextra-semi" #pragma clang diagnostic ignored "-Wmissing-braces" + #pragma clang diagnostic ignored "-Wshadow-field" #if __has_warning("-Wpragma-pack") #pragma clang diagnostic ignored "-Wpragma-pack" #endif diff --git a/modules/juce_core/native/juce_BasicNativeHeaders.h b/modules/juce_core/native/juce_BasicNativeHeaders.h index 7ff4e625bc..dc5d53c000 100644 --- a/modules/juce_core/native/juce_BasicNativeHeaders.h +++ b/modules/juce_core/native/juce_BasicNativeHeaders.h @@ -28,12 +28,20 @@ #if JUCE_MAC || JUCE_IOS #if JUCE_IOS + #if JUCE_MODULE_AVAILABLE_juce_opengl && defined (__IPHONE_12_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_12_0 + #define GLES_SILENCE_DEPRECATION 1 + #endif + #import #import #import #import #include #else + #if JUCE_MODULE_AVAILABLE_juce_opengl && defined (MAC_OS_X_VERSION_10_14) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 + #define GL_SILENCE_DEPRECATION 1 + #endif + #import #if (! defined MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 #define NSEventModifierFlagCommand NSCommandKeyMask diff --git a/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h b/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h index d082910cc2..afe32e69e6 100644 --- a/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h @@ -657,7 +657,7 @@ struct SIMDNativeOps static forcedinline __m128i JUCE_VECTOR_CALLTYPE greaterThan (__m128i a, __m128i b) noexcept { - #if defined(__SSE4_1__) + #if defined(__SSE4_2__) return _mm_cmpgt_epi64 (a, b); #else return SIMDFallbackOps::greaterThan (a, b); @@ -717,7 +717,7 @@ struct SIMDNativeOps static forcedinline __m128i JUCE_VECTOR_CALLTYPE greaterThan (__m128i a, __m128i b) noexcept { - #if defined(__SSE4_1__) + #if defined(__SSE4_2__) return _mm_cmpgt_epi64 (ssign (a), ssign (b)); #else return SIMDFallbackOps::greaterThan (a, b); diff --git a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm index 6d0c2e7010..3d4a76d583 100644 --- a/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm +++ b/modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm @@ -639,9 +639,10 @@ void CoreGraphicsContext::drawGlyph (int glyphNumber, const AffineTransform& tra { if (state->fontRef != nullptr && state->fillType.isColour()) { - #if JUCE_CLANG + #if JUCE_CLANG && ! (defined (MAC_OS_X_VERSION_10_16) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_16) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #define JUCE_DEPRECATION_IGNORED 1 #endif if (transform.isOnlyTranslation()) @@ -668,8 +669,9 @@ void CoreGraphicsContext::drawGlyph (int glyphNumber, const AffineTransform& tra CGContextRestoreGState (context); } - #if JUCE_CLANG + #if JUCE_DEPRECATION_IGNORED #pragma clang diagnostic pop + #undef JUCE_DEPRECATION_IGNORED #endif } else diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index 34d0d6a10e..9f4b548043 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -1086,7 +1086,7 @@ void Desktop::allowedOrientationsChanged() jassert (i < n); i = jmin (n - 1, i); - NSNumber *value = [NSNumber numberWithInt:Orientations::convertFromJuce (orientations[i])]; + NSNumber *value = [NSNumber numberWithInt: (int) Orientations::convertFromJuce (orientations[i])]; [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; [value release]; } diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 8914f72492..8c8797af4b 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -121,7 +121,6 @@ public: setAlwaysOnTop (true); [window setContentView: view]; - [window setAutodisplay: YES]; [window setAcceptsMouseMovedEvents: YES]; // We'll both retain and also release this on closing because plugin hosts can unexpectedly @@ -808,7 +807,7 @@ public: if (r.size.width < 1.0f || r.size.height < 1.0f) return; - auto cg = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; + auto cg = (CGContextRef) [[NSGraphicsContext currentContext] CGContext]; if (! component.isOpaque()) CGContextClearRect (cg, CGContextGetClipBoundingBox (cg)); @@ -1245,7 +1244,7 @@ public: static NSArray* getSupportedDragTypes() { - return [NSArray arrayWithObjects: NSFilenamesPboardType, NSFilesPromisePboardType, NSStringPboardType, nil]; + return [NSArray arrayWithObjects: (NSString*) kUTTypeFileURL, (NSString*) kPasteboardTypeFileURLPromise, NSPasteboardTypeString, nil]; } BOOL sendDragCallback (const int type, id sender) @@ -1260,8 +1259,8 @@ public: ComponentPeer::DragInfo dragInfo; dragInfo.position.setXY ((int) p.x, (int) ([view frame].size.height - p.y)); - if (contentType == NSStringPboardType) - dragInfo.text = nsStringToJuce ([pasteboard stringForType: NSStringPboardType]); + if (contentType == NSPasteboardTypeString) + dragInfo.text = nsStringToJuce ([pasteboard stringForType: NSPasteboardTypeString]); else dragInfo.files = getDroppedFiles (pasteboard, contentType); @@ -1284,7 +1283,7 @@ public: StringArray files; NSString* iTunesPasteboardType = nsStringLiteral ("CorePasteboardFlavorType 0x6974756E"); // 'itun' - if (contentType == NSFilesPromisePboardType + if ([contentType isEqualToString: (NSString*) kPasteboardTypeFileURLPromise] && [[pasteboard types] containsObject: iTunesPasteboardType]) { id list = [pasteboard propertyListForType: iTunesPasteboardType]; @@ -1310,14 +1309,14 @@ public: } else { - id list = [pasteboard propertyListForType: NSFilenamesPboardType]; + NSArray* items = [pasteboard readObjectsForClasses:@[[NSURL class]] options: nil]; - if ([list isKindOfClass: [NSArray class]]) + for (unsigned int i = 0; i < [items count]; ++i) { - NSArray* items = (NSArray*) [pasteboard propertyListForType: NSFilenamesPboardType]; + NSURL* url = [items objectAtIndex: i]; - for (unsigned int i = 0; i < [items count]; ++i) - files.add (nsStringToJuce ((NSString*) [items objectAtIndex: i])); + if ([url isFileURL]) + files.add (nsStringToJuce ([url path])); } } diff --git a/modules/juce_gui_basics/native/juce_mac_Windowing.mm b/modules/juce_gui_basics/native/juce_mac_Windowing.mm index 4137b841e8..b40684f5df 100644 --- a/modules/juce_gui_basics/native/juce_mac_Windowing.mm +++ b/modules/juce_gui_basics/native/juce_mac_Windowing.mm @@ -518,8 +518,8 @@ bool juce_areThereAnyAlwaysOnTopWindows() static void selectImageForDrawing (const Image& image) { [NSGraphicsContext saveGraphicsState]; - [NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithGraphicsPort: juce_getImageContext (image) - flipped: false]]; + [NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithCGContext: juce_getImageContext (image) + flipped: false]]; } static void releaseImageAfterDrawing() @@ -590,16 +590,16 @@ void SystemClipboard::copyTextToClipboard (const String& text) { NSPasteboard* pb = [NSPasteboard generalPasteboard]; - [pb declareTypes: [NSArray arrayWithObject: NSStringPboardType] + [pb declareTypes: [NSArray arrayWithObject: NSPasteboardTypeString] owner: nil]; [pb setString: juceStringToNS (text) - forType: NSStringPboardType]; + forType: NSPasteboardTypeString]; } String SystemClipboard::getTextFromClipboard() { - return nsStringToJuce ([[NSPasteboard generalPasteboard] stringForType: NSStringPboardType]); + return nsStringToJuce ([[NSPasteboard generalPasteboard] stringForType: NSPasteboardTypeString]); } void Process::setDockIconVisible (bool isVisible) diff --git a/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp b/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp index 886967f7a9..1a0feedd3f 100644 --- a/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp +++ b/modules/juce_gui_extra/native/juce_mac_SystemTrayIcon.cpp @@ -76,16 +76,17 @@ public: stopTimer(); // There's currently no good alternative to this... - #if defined __clang__ && defined (MAC_OS_X_VERSION_10_14) && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_14 - #define IGNORE_POPUP_DEPRECATION 1 + #if JUCE_CLANG && ! (defined (MAC_OS_X_VERSION_10_16) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_16) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #define JUCE_DEPRECATION_IGNORED 1 #endif [statusItem.get() popUpStatusItemMenu: m]; - #if IGNORE_POPUP_DEPRECATION + #if JUCE_DEPRECATION_IGNORED #pragma clang diagnostic pop + #undef JUCE_DEPRECATION_IGNORED #endif startTimer (1); diff --git a/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm b/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm index 97dd6f13db..6e3371f141 100644 --- a/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm +++ b/modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm @@ -24,6 +24,12 @@ ============================================================================== */ +#if JUCE_CLANG && ! (defined (MAC_OS_X_VERSION_10_16) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_16) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #define JUCE_DEPRECATION_IGNORED 1 +#endif + #if JUCE_MAC namespace juce @@ -359,6 +365,11 @@ private: #endif }; +#if JUCE_DEPRECATION_IGNORED + #pragma clang diagnostic pop + #undef JUCE_DEPRECATION_IGNORED +#endif + //============================================================================== WebBrowserComponent::WebBrowserComponent (bool unloadWhenHidden) : unloadPageWhenBrowserIsHidden (unloadWhenHidden) diff --git a/modules/juce_opengl/juce_opengl.h b/modules/juce_opengl/juce_opengl.h index c94561dcf7..7cc2d2b373 100644 --- a/modules/juce_opengl/juce_opengl.h +++ b/modules/juce_opengl/juce_opengl.h @@ -93,14 +93,20 @@ #undef KeyPress #elif JUCE_IOS #if defined (__IPHONE_7_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0 + #if defined (__IPHONE_12_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_12_0 + #define GLES_SILENCE_DEPRECATION 1 + #endif #include #else #include #endif #elif JUCE_MAC - #define JUCE_OPENGL3 1 - #include - #include + #define JUCE_OPENGL3 1 + #if defined (MAC_OS_X_VERSION_10_14) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 + #define GL_SILENCE_DEPRECATION 1 + #endif + #include + #include #elif JUCE_ANDROID #include #include diff --git a/modules/juce_opengl/native/juce_OpenGL_osx.h b/modules/juce_opengl/native/juce_OpenGL_osx.h index f73461f196..f5805fde3c 100644 --- a/modules/juce_opengl/native/juce_OpenGL_osx.h +++ b/modules/juce_opengl/native/juce_OpenGL_osx.h @@ -27,6 +27,12 @@ namespace juce { +#if JUCE_CLANG && ! (defined (MAC_OS_X_VERSION_10_16) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_16) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #define JUCE_DEPRECATION_IGNORED 1 +#endif + class OpenGLContext::NativeContext { public: @@ -205,7 +211,11 @@ public: minSwapTimeMs = (numFramesPerSwap * 1000) / 60; [renderContext setValues: (const GLint*) &numFramesPerSwap + #if defined (MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + forParameter: NSOpenGLContextParameterSwapInterval]; + #else forParameter: NSOpenGLCPSwapInterval]; + #endif return true; } @@ -213,7 +223,11 @@ public: { GLint numFrames = 0; [renderContext getValues: &numFrames + #if defined (MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + forParameter: NSOpenGLContextParameterSwapInterval]; + #else forParameter: NSOpenGLCPSwapInterval]; + #endif return numFrames; } @@ -252,4 +266,9 @@ bool OpenGLHelpers::isContextActive() return CGLGetCurrentContext() != CGLContextObj(); } +#if JUCE_DEPRECATION_IGNORED + #pragma clang diagnostic pop + #undef JUCE_DEPRECATION_IGNORED +#endif + } // namespace juce diff --git a/modules/juce_video/native/juce_mac_CameraDevice.h b/modules/juce_video/native/juce_mac_CameraDevice.h index 818f3e3caa..9fcfec845d 100644 --- a/modules/juce_video/native/juce_mac_CameraDevice.h +++ b/modules/juce_video/native/juce_mac_CameraDevice.h @@ -24,6 +24,12 @@ ============================================================================== */ +#if JUCE_CLANG && ! (defined (MAC_OS_X_VERSION_10_16) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_16) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #define JUCE_DEPRECATION_IGNORED 1 +#endif + struct CameraDevice::Pimpl { Pimpl (CameraDevice& ownerToUse, const String&, int /*index*/, int /*minWidth*/, int /*minHeight*/, @@ -328,3 +334,8 @@ String CameraDevice::getFileExtension() { return ".mov"; } + +#if JUCE_DEPRECATION_IGNORED + #pragma clang diagnostic pop + #undef JUCE_DEPRECATION_IGNORED +#endif