Am 04.02.2020 um 07:53 schrieb Shawn Rutledge:

On 1 Feb 2020, at 19:20, Daniel Teske <q...@squorn.de <mailto:q...@squorn.de>> wrote:

Now to take your next example: setParent is not fine. setParent can be used in 4 different ways:

child->setParent(child->parent()): Invariant holds
child->setParent(newParent): Invariant holds
child->setParent(nullptr): Nope
orphan->setParent(parent): Nope

The solution is I have is to replace setParent with two functions: adoptChild + releaseChild, which both ensure that the invariant always holds.

And to deprecate setParent. ...

In Qt Quick we plan to have a unified ownership tree in Qt 6: visual parent item will be the same as QObject parent.  (Whereas in Qt 5, QQuickItem::setParentItem() sets a different pointer.)  And Item.parent is a property, so it’s expected to be able to reparent a subtree of Items by setting its parent to a different one.  How do you think that should be handled?

You snipped out the relevant part that explains that there are new methods: adoptChild + releaseChild. So I don't see any problem?

daniel

_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to