Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
5.9.4
-
None
Description
QQuickControl has two places ( https://code.woboq.org/qt5/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp.html methods setContentItem_helper and setBackground ) where child item is just deleted without checking ownership. I guess there are many other places in other controls too, due to the usage of plain deletes in code. Maybe it would be better to have an helper method for unlinking control children within qquickitems in general. This method would check ownership and then either deletes or just set the pointer to nullptr.
Background:
Approach 1: Presenting over an Loader (working):
- Load an QQmlComponent component in c++
- Have an Loader component in qml
- Bind the QQmlComponent to Loaders SourceComponent(:Component) property
- -> Rebinding the property works and updates presentation (incubating an new delegate)
Approach 2: Presenting over Content Presenter (not working)
- Load an QQmlComponent component in c++
- Incubate an QQuickItem in c++ and set Ownership to CppOwnership
- Optional handle bindings with an QQmlContext in c++
- Have an Control Item in qml
- Bind the QQuickItem to Controls background(:Item) or contentItem(:Item) property
- -> Rebinding works and updates presentation. However it deletes the old incubated QQuickItem also it should not (CppOwnership)
Attachments
Issue Links
- duplicates
-
QTBUG-72085 Rethink how we manage the lifetime of controls' building blocks
- Closed