PluginEditor construction happens twice

Hi,

I noticed that this first in a plugin I am working on but I took a look at the JuceDemoPlugin and the PluginEditor construction is also being carried out twice.

Wondering if this is a bug in JUCE or perhaps with the demo ?

Does it happen because of what the host using the plugin does? In any case, you should be prepared for things like that to happen. Just be careful to not leak any memory when the plugin GUI is created and destroyed multiple times.

I have been testing it within Cubase 8

I’ve checked it with another host (MuLab) which I use for quick debugging and it constructs twice there as well.

It isn’t really causing any serious issue for me it just seemed to be an anomaly.

I found it while debugging.

Some hosts create it twice to get the window size.

Yes - I can see why hosts might construct a plugin twice -lets them have a sneaky peek first.

Yes many hosts create the plug-in editor twice.

Don’t mean to resurrect an old thread, but I’ve noticed this issue a few times and was always curious as to why it happened. The issue it caused for me was, when displaying a nag screen in the constructor of the pluginEditor, the user would have to dismiss it twice, as the constructor is called twice. Any good work arounds for this? I want it to be a nag screen to purchase, but I don’t want them to have to click twice.

Sorry, there is nothing that we can do about this. If the hosts asks the plug-in to open it’s editor twice in a row, well then there is nothing we can do about that.

Perhaps try only showing the nag only after a short timer so it doesn’t pop up if the host is just doing a quick instantiation of the editor. Also use a member variable to record whether you’ve already displayed the nag so don’t show it again if user closes then opens the editor later on.

It’d be much better UX to show the nag screen as an overlay inside your editor rather than a separate box.

You could trigger the nag screen in prepareToPlay(). (that’s what I do + my nagscreen is an overlay as jules suggested.)
Only make sure not to block anything with the nag screen. That would be a bit too much nagging and might cause people to loose confidence in the quality of your products.

Sounds good! I’ll give this a try when I get back home! Thanks for the tip!

This sounds as much arbitrary as the original solution if not a little worse: to my knowledge the prepareToPlay() may be called multiple times during plug-in initialization, AND the Editor at those times is not even guaranteed to be existing and showing.

1 Like

I was the OP

I really only raised the subject to make sure I wasn’t missing something as it had no real affect on my dev at the time but just seemed an oddity.

But I can see the use in having places to hang singular events like a nag screen.

with audio plugins it isn’t a problem to handle it as time is part of the pact.

But for consistency it would probably be a good to have a hook for such things