qt: leverage JS engine garbage collection and declaratively assign the model in `VideoAllSubDisplay.qml`
Imperatively assigning the model is problematic here, because the model may be accessed before it is assigned.
With declarative approach, it is the QML engine's responsibility make sure the model is assigned at appropriate time before it is accessed.
Qt documentation states that [1]:
If a parent is not provided to createObject(), a reference to the returned object must be held so that it is not destroyed by the garbage collector. This is true regardless of whether Item::parent is set afterwards, because setting the Item parent does not change object ownership. Only the graphical parent is changed.
Since the old model is no longer referenced anymore after
MainCtx.grouping
changes, this approach should be fine.
I have tested this on both Qt 6.2 and 6.8.
[1] https://doc.qt.io/qt-6/qml-qtqml-component.html#createObject-method
This was first discussed in !5890 (comment 479041).
Request review @chub.