3 ms·
This is very true. What did you use instead? wxWidgets is the same - when a wxWindow gets deleted, it will remove its children in the view hierarchy, which are
by 72deluxe 11y ago
This is very true. What did you use instead?
wxWidgets is the same - when a wxWindow gets deleted, it will remove its children in the view hierarchy, which are likely not children of it as data members. I think a lot of this comes from the fact that underneath native pointers are being used (eg handles on Windows) and widgets/controls are not necessarily going to be data members of a parent. It also means you can reparent widgets/controls to other GUI items at runtime. I do this (for example) when switching notebook pages to rehouse a GUI element in order to save RAM; I just assign it new data to display and it means less RAM usage and creation time for each notebook page.
For your own data controls, we can still ensure that they clean themselves up alright and safely, just use pointers for the GUI items. In some sense, the GUI toolkit takes care of deleting its own members, eg. wxWidgets will delete all of a parent wxWindow children at teardown, so it isn't a leak situation.
- 0xcde4c3db 11y ago> This is very true. What did you use instead? Since I was looking at it for hobby/educational projects, I basically decided to not do something with a GUI. I think I had also looked at wxWidgets and FLTK, hoping that one of them was cleaner and more modern; FLTK managed the "cleaner" part, at least. The last time I looked at C++ GUI libraries it seemed like JUCE was the most promising, but it also had a bit of weirdness (GPL license without linking exception, heavy bias toward audio applications).