which one? why?
I have a class that i'm trying to make static in my project. it needs access to some fonts that i've stored as a SharedResourcePointer through-out my other classes in the project as each module uses the fonts. When my app closes, i'm getting a LeakCounter jassertfalse on the SharedResourcePointer for one of my font objects when this singleton class tries to destruct.
If you're writing a juce-based singleton using the macros, your class should inherit from DeletedAtShutdown.
https://www.juce.com/doc/classDeletedAtShutdown
Even better is a Myers singleton, though its use may be circumstancial. Example:
static Singleton& getInstance()
{
static Singleton s;
return s;
}
As for singleton vs SharedResourcePointer: I guess it depends! Jules wrote a bit about it here: http://www.juce.com/forum/topic/sharedresourcepointer
3 Likes