1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

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

This commit is contained in:
ed 2019-03-13 15:04:03 +00:00
parent 11c8a4d1e6
commit 61637218a2
3 changed files with 20 additions and 19 deletions

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

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

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