qt5base-lts/tests/auto
Fabian Kosmale f1b1773d0a QProperty: Notify observers even when dependency is gone
Problem description:
--------------------
Assume we have two properties, P1 and P2. Assume further that we assign
a binding to P2, so that it depends on P1. Let the binding additionally
capture some (non-QProperty) boolean, and only create the dependency to
P1 if the boolean is true.

The state afterwards is
P1:[p1vaue|firstObserver]
                      |
                      |
                      v
                ---[p2binding]
	       /
P2:[p2value|binding]

If the boolean is set to false, and P1 changes its value, we still
correctly re-evaluate the binding and update P2's value. However, during
binding evaluation we will notice that there is no further dependency
from P2 on P1, and remove its observer.

The state afterwards is
P1:[p1vaue|firstObserver=nullptr]

                ---[p2binding]
	       /
P2:[p2value|binding]

Then, during the notify phase, we traverse the observer's again,
starting from P1's firstObserver. Given that it is nullptr now, we never
reach P2's binding, and thus won't send a notification from it.

Fix:
----

We store a list of all visited binding-observers (in a QVarLengthArray,
to avoid allocations as long as possible). After the binding evaluation
phase, we then use that list to send notifications from every binding
that we visited. As we already have a list of all bindings, we no longer
need to recurse on binding-observes during the notification process;
instead, we only need to deal with static callbacks and ChangeHandlers.

The pre-existing notification logic is still kept for the grouped update
case, where we already have a list of all delayed properties, and should
therefore not encounter the same issue. Unifying its codepath with the
existing logic is left as an exercise for a later patch.

Fixes: QTBUG-105204
Task-number: QTBUG-104982
Pick-to: 6.4 6.3 6.2
Change-Id: I2951f7d9597f4da0b8560a64dfb834f7ad86e757
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-08-01 12:08:26 +02:00
..
bic/data Add BiC data for the new way to do BiC testing 2022-05-12 13:33:41 +03:00
cmake Fix memory leaks 2022-06-15 23:58:16 +02:00
concurrent CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
corelib QProperty: Notify observers even when dependency is gone 2022-08-01 12:08:26 +02:00
dbus CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
gui CMake: Remove unnecessary INCLUDE_DIRECTORIES . in tests 2022-07-28 14:46:53 +02:00
guiapplauncher Move QStateMachine from QtCore to QtScxml 2020-08-24 20:10:25 +02:00
network CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
opengl Remove the qmake project files 2021-01-07 15:32:28 +01:00
other CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
printsupport CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
shared Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
sql CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
testlib CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
tools CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
wasm CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
widgets CMake: Remove unnecessary INCLUDE_DIRECTORIES . in tests 2022-07-28 14:46:53 +02:00
xml CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
CMakeLists.txt Only configure one test for wasm 2022-05-12 18:55:04 +02:00
network-settings.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00