Custom LookAndFeel weirdness when multiple editors open

Hey,

I’m encountering some weirdness in relation to a custom LookAndFeel. When I have multiple instances of the plug-in instantiated on different tracks and open and close the editor, every now and then a plug-in editor will appear that has no look and feel applied and the plugin crashes. My feeling is that there is some form of sharing between plug-in instances of the LookAndFeel.

In the editor I do this, with myLnF a ScopedPointer.

//===========================================
MyAudioProcessorEditor::MyAudioProcessorEditor (MyAudioProcessor& p){

myLnF = new LookAndFeel_Mine();
LookAndFeel::setDefaultLookAndFeel(mainLnF);

}

MyAudioProcessorEditor::~MyAudioProcessorEditor()
{

setLookAndFeel(nullptr);
LookAndFeel::setDefaultLookAndFeel (nullptr);

}

setDefaultLookAndFeel is a static method so will apply to all your plugin instances if they’re being hosted in the same process.

Do you need to set a default look and feel? (The only reason I can think of for this is for custom fonts).
The slightly better approach is to use a SharedResourcePointer<LookAndFeel_Mine> and then don’t clear the default look and feel in the destructor.

1 Like

Yeah, we use the custom look and feel for lots of things, included our own embedded typeface.

So what it would be then is:
In MyAudioProcessorEditor.h
MyAudioProcessorEditor{

SharedResourcePointer<LookAndFeel_Mine> mainLnf;
}

In MyAudioProcessorEditor.cpp
//===========================================
MyAudioProcessorEditor::MyAudioProcessorEditor (MyAudioProcessor& p){

LookAndFeel::setDefaultLookAndFeel(mainLnF);

}

MyAudioProcessorEditor::~MyAudioProcessorEditor()
{
setLookAndFeel(nullptr);
}

Hi Gav,

I suggest you to indent all your code with 4 spaces when you type your post, this will give it a fixed width font and make it more readable.

like this, for example

Or simply type three backticks before and after it to achieve the same result:

```
like this
```

Also, you can do the same by selecting the code parts of your post and clicking the “preformatted text tool”, which has an icon like this: </>