How to handle hosted VSTs editors inside another VST?

Hello guys, first let me tell you that this library is amazing, really well crafted.

I tried creating some simple plugs for testing and learning dsp, and so far has been a breeze, now i want to create a little more complicated rack.

So im building a small plugin rack, this is a vst that hosts other vsts, so far i had great success using the audioprocessorgraph on my PluginProcessor.cpp prepareToPlay function, i load a simple vst, and it works (juce DBG method is pretty handy there) but how do i handle the editor of this plugin, i tried the plugin host code app, but it seems to use delete this on the closeButtonPressed, and it seems to stack all the pointers in some sort of array, i tried this, but i get awful crashes when closing the parent vst without closing the windows.

So this is what i tried:

Create the editors from the PluginEditor.cpp class, on the constructor i check if the processor is not a null ptr, then i call getWindowFor on PluginWindow, it works (had to remove the static array stuff), but how do i close it, should PluginWindow take ownership of it?

Please ill be very greateful if anyone can point me in the right direction: how should i handle the editors ?



Hello, glad you like it!

I'm actually building a plugin-hosting plugin at the moment for a client, so have been doing this myself. The window that you pop out to contain the sub-plugin's AudioProcessorEditor should own and delete that editor component - I'm just using a DocumentWindow subclass and setContentOwned (audioProcessorEditor, true) to display it. If you're getting crashes then your ownership of the DocumentWindow is probably a bit dodgy and you're deleting it twice somehow. Just make sure it's only owned/deleted by one thing.

Jules, thank you so much for answering !

So my VST is a generic plugin created with the introjucer, so it has PluginEditor and PluginProcessor, does PluginEditor should be the one taking ownership of the created window? if so, should the Editor in its destructor call delete to the window containing the editor component?

I subclassed DocumentWindow, and maintained the getWindowFor factory you created for the PluginHost , so in the constructor of the editor i get a node from a graph contained in the AudioProcessor, this node contains a pluginInstance, then i pass that instance to the factory and create a window, works great, now if i close the window, it works alright, if i leave the hosted plugin open and delete/remove the plug, i crash. this happens if i use deleteAndZero(testPlugEditor) on the destructor on the Editor, if i dont do it, then i leak and crash.

Should the created window be a scopedpointer in the heap of the editor? (think i already tried it, and it also crashed)

Am i totally lost? Should i just quit and become an astronaut?


Heh i'll again point you to something like that i already wrote, it seemed to work fine (my friend used it for production). the code is open and is available at:

Hi Atom, thanks for your reply, i found your code a few days ago, and it helped me a lot,  however it differs of what i'm trying to do.

Your code  on Morph seems to fill the default PluginEditor component, i want to open it in a separate window like the PluginHost, this window must be created by the default PluginEditor.cpp.

My current problem is:

I leak if i delete the created window, and I crash if I do. 0.0


How about a piece of code that's at fault, im sure we can figure something out.

Hey Atom, thanks for your help.

Here is a repo with the least amount of code necessary for this:

Check the PluginEditor destructor, it enlists the stuff ive tried.

Hope anyone can guide me in the right direction.

Thanks guys :)

I had similar issues , i always tracked them with a debugger. Anyway a long time ago i wrote a plugin that hosts other plugins AND opens each editor in a seperate window, that is what you are trying to do i think, th code is here:  the class is ShredderPluginEditor. I think it was working fine and I didn't get any crashes back then.


I tested your code and it seems fine with the first option in the dtor

   if (testPlugWindow != nullptr)
        deleteAndZero (testPlugWindow);

I just initialized testPluginWindow to nullptr in the ctor of the class.

But i'm testing this on Windows, and I see you are doind your work on OSX and i know that in terms of VST

this can be a big difference. Look at the stack trace when your code crashes, i turned on Assertion logging

in JUCE and that helps to catch basic mistakes (if you leave components on the desktop that should already

be deleted etc.)

From a quick glance I think you should add clearContentComponent () to your SimplePluginWindow destructor

I have a highly related question about destroying sub-plugin editors before the plugins themselves are destroyed. It seems like the people in this thread could have really useful advice.

If you guys wouldn't mind having a glance.


Also wondering how you guys managed to get the PluginWindow to ignore key presses. 

I tried 

    subPluginWindow = new PluginWindow();


But this doesn't seem to do the trick. I have no issue when the focus is on the HostingPluginEditor, only when the focus is on the SubPluginEditor window.