@@ -47,6 +47,23 @@ static void initJuceDevices() | |||
manager.createAudioDeviceTypes(gJuceDeviceTypes); | |||
} | |||
// ------------------------------------------------------------------------------------------------------------------- | |||
// Cleanup | |||
static struct JuceCleanup { | |||
JuceCleanup() {} | |||
~JuceCleanup() | |||
{ | |||
if (gRetNames != nullptr) | |||
{ | |||
delete[] gRetNames; | |||
gRetNames = nullptr; | |||
} | |||
gJuceDeviceTypes.clear(true); | |||
} | |||
} sJuceCleanup; | |||
// ------------------------------------------------------------------------------------------------------------------- | |||
// Juce Engine | |||
@@ -68,14 +85,6 @@ public: | |||
~CarlaEngineJuce() override | |||
{ | |||
carla_debug("CarlaEngineJuce::~CarlaEngineJuce()"); | |||
if (gRetNames != nullptr) | |||
{ | |||
delete[] gRetNames; | |||
gRetNames = nullptr; | |||
} | |||
gJuceDeviceTypes.clear(true); | |||
} | |||
// ------------------------------------- | |||
@@ -135,6 +135,23 @@ static RtMidi::Api getMatchedAudioMidiAPi(const RtAudio::Api rtApi) | |||
return RtMidi::UNSPECIFIED; | |||
} | |||
// ------------------------------------------------------------------------------------------------------------------- | |||
// Cleanup | |||
static struct RtAudioCleanup { | |||
RtAudioCleanup() {} | |||
~RtAudioCleanup() | |||
{ | |||
if (gRetNames != nullptr) | |||
{ | |||
delete[] gRetNames; | |||
gRetNames = nullptr; | |||
} | |||
gRtAudioApis.clear(); | |||
} | |||
} sRtAudioCleanup; | |||
// ------------------------------------------------------------------------------------------------------------------- | |||
// RtAudio Engine | |||
@@ -165,14 +182,6 @@ public: | |||
fUsedMidiIns.clear(); | |||
fUsedMidiOuts.clear(); | |||
if (gRetNames != nullptr) | |||
{ | |||
delete[] gRetNames; | |||
gRetNames = nullptr; | |||
} | |||
gRtAudioApis.clear(); | |||
} | |||
// ------------------------------------- | |||
@@ -29,6 +29,7 @@ | |||
#ifndef JUCE_LEAKEDOBJECTDETECTOR_H_INCLUDED | |||
#define JUCE_LEAKEDOBJECTDETECTOR_H_INCLUDED | |||
#define DBG2(dbgtext) { juce::String str; str << dbgtext; std::cout << str.toRawUTF8() << std::endl; } | |||
//============================================================================== | |||
/** | |||
@@ -55,7 +56,7 @@ public: | |||
{ | |||
if (--(getCounter().numObjects) < 0) | |||
{ | |||
DBG ("*** Dangling pointer deletion! Class: " << getLeakedObjectClassName()); | |||
DBG2 ("*** Dangling pointer deletion! Class: " << getLeakedObjectClassName()); | |||
/** If you hit this, then you've managed to delete more instances of this class than you've | |||
created.. That indicates that you're deleting some dangling pointers. | |||
@@ -68,7 +69,7 @@ public: | |||
your object management. Tut, tut. Always, always use ScopedPointers, OwnedArrays, | |||
ReferenceCountedObjects, etc, and avoid the 'delete' operator at all costs! | |||
*/ | |||
jassertfalse; | |||
//jassertfalse; | |||
} | |||
} | |||
@@ -83,7 +84,7 @@ private: | |||
{ | |||
if (numObjects.value > 0) | |||
{ | |||
DBG ("*** Leaked objects detected: " << numObjects.value << " instance(s) of class " << getLeakedObjectClassName()); | |||
DBG2 ("*** Leaked objects detected: " << numObjects.value << " instance(s) of class " << getLeakedObjectClassName()); | |||
/** If you hit this, then you've leaked one or more objects of the type specified by | |||
the 'OwnerClass' template parameter - the name should have been printed by the line above. | |||
@@ -92,7 +93,7 @@ private: | |||
your object management. Tut, tut. Always, always use ScopedPointers, OwnedArrays, | |||
ReferenceCountedObjects, etc, and avoid the 'delete' operator at all costs! | |||
*/ | |||
jassertfalse; | |||
//jassertfalse; | |||
} | |||
} | |||