Browse Source

macOS: Fixed a couple of places where CFStrings weren't being released properly

tags/2021-05-28
ed 6 years ago
parent
commit
61637218a2
3 changed files with 20 additions and 19 deletions
  1. +3
    -18
      modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp
  2. +3
    -1
      modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm
  3. +14
    -0
      modules/juce_core/native/juce_osx_ObjCHelpers.h

+ 3
- 18
modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp View File

@@ -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));
}


+ 3
- 1
modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm View File

@@ -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);


+ 14
- 0
modules/juce_core/native/juce_osx_ObjCHelpers.h View File

@@ -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

Loading…
Cancel
Save