Browse Source

VST2: Cleanup created objects on module/dll unload

Signed-off-by: falkTX <falktx@falktx.com>
pull/327/head
falkTX 3 years ago
parent
commit
37eb4c0832
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
1 changed files with 17 additions and 1 deletions
  1. +17
    -1
      distrho/src/DistrhoPluginVST2.cpp

+ 17
- 1
distrho/src/DistrhoPluginVST2.cpp View File

@@ -42,6 +42,7 @@
#define VST_FORCE_DEPRECATED 0

#include <clocale>
#include <list>
#include <map>
#include <string>

@@ -1635,6 +1636,20 @@ static void vst_processReplacingCallback(AEffect* effect, float** inputs, float*
#undef validPlugin
#undef vstObjectPtr

static struct Cleanup {
std::list<AEffect*> effects;

~Cleanup()
{
for (std::list<AEffect*>::iterator it = effects.begin(), end = effects.end(); it != end; ++it)
{
AEffect* const effect = *it;
delete (VstObject*)effect->object;
delete effect;
}
}
} sCleanup;

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO
@@ -1714,12 +1729,13 @@ const AEffect* VSTPluginMain(audioMasterCallback audioMaster)
effect->processReplacing = vst_processReplacingCallback;

// pointers
VstObject* const obj(new VstObject());
VstObject* const obj = new VstObject();
obj->audioMaster = audioMaster;
obj->plugin = nullptr;

// done
effect->object = obj;
sCleanup.effects.push_back(effect);

return effect;
}


Loading…
Cancel
Save