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:
parent
11c8a4d1e6
commit
61637218a2
3 changed files with 20 additions and 19 deletions
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue