Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.15.0
Description
Using a required property inside a View or Repeater prevents destructors from being called on custom C++ types created by the delegate. This occurs if the required property is declared in the view's delegate directly or wrapped in a type used by the delegate.
Furthermore, when a custom QML type (MyQmlType attached) was used to introduce a required property, the 'model' keyword became unavailable in the delegate. Based on the model-view documentation for required properties, I had expected the 'model' keyword to be removed only for top level required properties. Allowing subcomponents to trigger this behavior limits reusability.
Example code is attached. QDebug print statements were used to track MyType object creation and destruction.
When 'regular' properties are used, MyType is created and destroyed as expected:
MyType Created
MyType Created
MyType Created
MyType Deleted
MyType Deleted
MyType Deleted
When a 'required' property is introduced, at any level in the delegate, the MyType destructor is no longer called:
MyType Created
MyType Created
MyType Created