setDefaultLookAndFeel


#1

Hi,

I am hitting some crashes when loading then unloading multiple instances of my plugin.

As soon as I unload one instance, I get a crash both on VST (win, mac) and AU, although the behavior is slightly different on mac: I can move my mouse over the components, which are redrawn using the default L+F, and the crash occurs quickly afterwards.

I am pretty sure that it is due to me calling setDefaultLookAndFeel in my plugin’s constructor as I’m getting the same issue with the juce demo when throwing in a basic custom L+F and setting it as default.

I reckon it is not safe to use statics when multiple instances may be used, but should one just stay away from setDefaultLookAndFeel when making a plug-in or is there a way out?

Also, should I expect more “static” troubles once I’ve got rid of the look and feel problem?

Thank you for help!


#2

use Singleton and DeletedAtShutdown

http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=4642&hilit=lookandfeel+plugin

All you need is:

    class NewLook  : public LookAndFeel, public DeletedAtShutdown
    {
        juce_DeclareSingleton (NewLook)
        etc...
    }

and then just call:


    LookAndFeel::setDefaultLookAndFeel (NewLook::getInstance())

…as often as you like.


#3

Damn, how could I miss this post… Thank you!