It wasn’t until after I wrote lots of code that I eventually stumbled upon ScopedPointers, and I have recently gone through lots of code and converted any Component ptrs to ScopedPointers. I used to use deleteAllChildren() in my class destructors to help tidy up, although, if only using ScopedPointers is this ever necessary?
To test I made a simple class that creates a TabbedComponent (scopedptr) and a scopedptr instance of a custom class that subclasses Component. It seems to shutdown just fine without any leaked components or warning. If I add deleteAllChildren() in the destructor, I get the following: "malloc: *** error for object 0xe34180: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug
Does this mean that the ptr/object is already freed and deleted before deleteAllChildren() trys to free and delete it(or vice versa)? Anyway, looks like I don’t need deleteAllChildren() but thought I’d ask as it would probably be good to fully understand, and also in case there are instances where I have ScopedPointers, and want to still use deleteAllChildren() (if there was a good reason?)…
edit: originally wrote safeptr instead of scopedptr