I've just started using the PropertiesFile class in my app, and want to share settings among components.
I am thinking of warpping it in a class that inherits ReferenceCountedObject so can safely pass a pointer around.
I'm planning to initialise it in MainContentComponent and then pass the pointer along as a constructor argument when subcomponents are created. This is how I'm currently sharing other objects across components.
Is this good practice or is there a more suitable method?
Personally, for a singleton type object like a PropertiesFile I would use a SharedResourcePointer. Just keep one alive in your JUCEApplication subclass and then create one whenever you need it. This saves storing and passing reference counted pointers around.
I also reorganised the code like the Introjucer, putting the contents of Main.cpp into Application.h, apart from the last line which is then the only thing in Main.cpp:
This allows including the header in other classes so they can access the shared pointers in the JUCEApplication instance.
I think it would be good to have a project template like this as I guess its a common pattern... as soon as you want multiple views/components sharing data, having everything going on in MainContentComponent doesnt make sense..