On Tue, Feb 04, 2020 at 07:17:13PM +0200, Ville Voutilainen wrote: > On Tue, 4 Feb 2020 at 18:48, Volker Hilsheimer <[email protected]> > wrote: > > >>> But that just means that QBoxLayout::addWidget(std::unique_ptr<>) has to > > >>> behave imho saner in that edge case and actually delete the widgets that > > >>> were added but never parented. (And I should really implement that to > > >>> show > > >>> how it would work.) > > >> > > >> > > >> That seems like a terrible idea. One of the layout’s jobs is to set up > > >> the > > >> parent/child hierarchy so that you as a developer don’t have to. > > > > > > I don't see how that idea changes that. > > > > > > Iif the layout deletes widgets that were created without parent, instead of > > adding it to the correct parent, then that’s a change. You have to create > > widgets with parents, and add them to the layout (which might then add it to > > another parent, which at the very least introduces unnecessary overhead of > > ChildAdded/Removed event processing). > > Right; the layout shouldn't insta-kill parentless children without trying to > reparent them first. > > > >> Do we really want to make it harder for people to write UIs just because > > >> the resulting code doesn’t satisfy a C++ idiom? > > > It's not a question of satisfying idioms for the sake of satisfying > > > idioms, > > > it's a question of avoiding bugs that we know based on decades of > > > experience > > > to be difficult to avoid with raw pointers. > > That’s my point: I do not believe that the decades of experience we have > > with > > QObject’s parent/child model support the claim that it is inferior to using > > smart-pointers. It’s not something people constantly struggle with. > > I have a completely polar opposite experience, it's the main source of memory > leaks and double deletes in Qt application code.
> [...] > Your experience suggests that this is not something people constantly > struggle with, my experience suggests that it's the #1 top-priority bug in Qt, > hands down, no competition. *shrug* I am with Volker here. Seriously, *double deletion*? In real, proper Qt-style code? The only problem is with people passing out when seeing different numbers of 'new' and 'delete'. And it's only a *real* problem when do not they take "Relax, it's ok" as an answer, and start to actively interfere. And that's when double deletion comes into play. > > If you understand Qt (and don’t assume that by understanding some basic C++ > > concepts you can use any framework), then you see that widgets are added to > > a > > layout that is used, and are therefore managed objects. > > Managed by what? Also, it seems downright detrimental if understanding basic > C++ > concepts is useless with Qt. I don't think that's received as much of an insult as you meant it to be by parts of your audience. Not requiring the verbosity of "basic C++" in user code is surely a benefit of Qt for me, and if people are appalled by not getting that with Qt, well, not my problem. Andre' _______________________________________________ Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
