diff --git a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp index 781dbfa512..5ae9155f72 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp @@ -29,21 +29,6 @@ namespace juce namespace CoreMidiHelpers { - //============================================================================== - struct ScopedCFString - { - ScopedCFString() = default; - ScopedCFString (String s) : cfString (s.toCFString()) {} - - ~ScopedCFString() noexcept - { - if (cfString != nullptr) - CFRelease (cfString); - } - - CFStringRef cfString = {}; - }; - //============================================================================== static bool checkError (OSStatus err, int lineNum) { @@ -195,9 +180,9 @@ namespace CoreMidiHelpers uniqueID = JUCE_STRINGIFY (JucePlugin_CFBundleIdentifier); #else auto appBundle = File::getSpecialLocation (File::currentApplicationFile); + ScopedCFString appBundlePath (appBundle.getFullPathName()); - if (auto bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault, appBundle.getFullPathName().toCFString(), - kCFURLPOSIXPathStyle, true)) + if (auto bundleURL = CFURLCreateWithFileSystemPath (kCFAllocatorDefault, appBundlePath.cfString, kCFURLPOSIXPathStyle, true)) { auto bundleRef = CFBundleCreate (kCFAllocatorDefault, bundleURL); CFRelease (bundleURL); @@ -259,7 +244,7 @@ namespace CoreMidiHelpers enableSimulatorMidiSession(); - CoreMidiHelpers::ScopedCFString name (getGlobalMidiClientName()); + ScopedCFString name (getGlobalMidiClientName()); CHECK_ERROR (MIDIClientCreate (name.cfString, &globalSystemChangeCallback, nullptr, &globalMidiClient)); } diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index 2e7e75533c..6a02e19618 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -428,7 +428,9 @@ public: { AudioUnitParameterValueFromString valueString; valueString.inParamID = paramID; - valueString.inString = text.toCFString(); + + ScopedCFString cfInString (text); + valueString.inString = cfInString.cfString; UInt32 propertySize = sizeof (valueString); diff --git a/modules/juce_core/native/juce_osx_ObjCHelpers.h b/modules/juce_core/native/juce_osx_ObjCHelpers.h index d98af4f803..fca469285a 100644 --- a/modules/juce_core/native/juce_osx_ObjCHelpers.h +++ b/modules/juce_core/native/juce_osx_ObjCHelpers.h @@ -412,5 +412,19 @@ private: BlockType block; }; +struct ScopedCFString +{ + ScopedCFString() = default; + ScopedCFString (String s) : cfString (s.toCFString()) {} + + ~ScopedCFString() noexcept + { + if (cfString != nullptr) + CFRelease (cfString); + } + + CFStringRef cfString = {}; +}; + } // namespace juce