Beginners question about Component::setVisible()



When I try to do a setVisible() on my child-components in a "main" component the program/plugin instantly crashes with a bad access code error. If I use the setVisible() method directly in the child components it works okay .. as a sidenote any attempt to access the pointer gives me a bad access code error..  a simple check if the pointer is a nullptr makes it go nuts as well :P


Are there any "laws" I should follow when I have a plugin with a "MainEditor" component that contains different "views" made up of child components that I want to set visible/invisible ? This was a little confusing, I could provide the actual code if it's necessary.. 


Any tips would be nice as I've literally just started testing JUCE and got stuck at this point already.. ;)


This used to happen to me very often when trying to resize any of the child components in the parent in the resized() method, if you use pointers there you need to make sure they are valid (all the components are created before any calls to setSize in the parent). But that's just me beeing stupid.

A piece of code will help i'm sure.