Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.0.0, 6.0
-
None
Description
New bindable properties build a dependency graph when bindings are executed. For this to work, there are some magic classes which execute some logic when being read.
All those magic classes, i.e. QProperty<T>, QObjectBindableProperty, and QObjectComputedProperty, when being read, they do the following: They check whether there is currently a binding evaluated (there is a thread-global object to store that) and if there is a binding currently being evaluated, they conclude they are a dependency of that binding and install an "observer". So in the future, when they change, they will notify this observer.
For this to work, it is required that the read actually happens from one of those magic objects.
This implies that the READ function for a computed property has to read from the underlying QObjectComputedProperty, otherwise dependency handling does not work.
I got this wrong first when porting QItemSelectionModel, so this implementation of "hasSelection" did not work:
https://codereview.qt-project.org/c/qt/qtbase/+/327044/2
I had to rename "hasSelection" to "hasSelectionActualComputation", use that as the computation function for the Q_OBJECT_COMPUTED_PROPERTY and create a new "hasSelection" to read from the computed property object.
Same problem exists with "isActive()" in
https://codereview.qt-project.org/c/qt/qtbase/+/326654/2
and with "activeThreadCount()" in
https://codereview.qt-project.org/c/qt/qtbase/+/326626/8/
.
Attachments
Issue Links
- is required for
-
QTBUG-85520 Use new QProperty in QtBase Foundation classes released with Qt 6.0
-
- Closed
-