Best place for custom look instantiation in a plugin?

gui

#1

I have a verrry sporadic bug on a plugin. (est. 1 run in 500 ish???)

The custom look (knob/slider drawing etc.) doesn’t load and the plugin draws with the default JUCE widgets.

Reloading the DAW session and drawing is back to correct custom widgets.

Where is the best place to instantiate the look?

Is there somewhere I can put it so that it periodically re-instantiates? (So if the bug does happen, it’s only for a split second?

Right now it’s a member variable of PluginProcessor
CustomLook look;

And is the first call in the constructor of PluginProcessor
LookAndFeel::setDefaultLookAndFeel (&look);


createFileBrowserGoUpButton()?
FileBrowserComponent colours
#2

just add that to the members of your pluginEditor :

 struct DefaultPluginLookAndFeel
 {
     DefaultPluginLookAndFeel()  { LookAndFeel::setDefaultLookAndFeel (&customLook); }
     ~DefaultPluginLookAndFeel() { LookAndFeel::setDefaultLookAndFeel (nullptr); }

     CustomLook customLook;
 };

 SharedResourcePointer<DefaultPluginLookAndFeel> lnf;

#3

Thank you so much @lalala! I just ran into a similar situation, where I needed to call setDefaultLookAndFeel before other members of my AudioProcessorEditor instantiated, and this did the trick!


#4

Brilliant @lalala and now I’ve learned about SharedResourcePointers!

Any ideas why my sporadic bug was appearing?