qt5base-lts/tests/auto/corelib/kernel
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
..
qapplicationstatic Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qcoreapplication CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
qdeadlinetimer Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qelapsedtimer Use debug stream in QTest::toString's default fallback if possible 2022-07-13 15:14:35 +02:00
qeventdispatcher Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qeventloop CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
qjnienvironment Add support for scoped JNI callbacks 2022-07-07 13:35:08 +03:00
qjniobject QJniObject: Add template overloads for get/setStaticField 2022-07-12 13:25:04 +02:00
qjnitypes Add compile-time generation of JNI class names 2022-05-27 22:27:13 +02:00
qmath Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmetacontainer CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
qmetaenum Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmetamethod Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmetaobject QMetaObject: rewrite QMetaMethod::invoke 2022-07-28 11:50:12 -07:00
qmetaobjectbuilder CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
qmetaproperty Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmetatype tst_QMetaType: fix warning that buffer may be unused 2022-07-31 08:00:11 -07:00
qmimedata CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
qobject QMetaType: disable conversion from smart pointer<const QObject> 2022-05-21 11:43:59 +02:00
qpointer CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
qproperty QProperty: Notify observers even when dependency is gone 2022-08-01 12:08:26 +02:00
qsharedmemory CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
qsignalblocker Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qsignalmapper Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qsocketnotifier CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
qsystemsemaphore CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
qtimer CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
qtranslator Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qvariant CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
qwineventnotifier CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers 2022-07-28 14:46:53 +02:00
CMakeLists.txt Generate JNI signature strings at compile time 2022-05-05 07:29:25 +02:00