diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-05-21 14:56:43 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-05-23 10:46:03 +0000 |
commit | 3f7741000ccf058212da26c7dc4ab4c8b4c9c0f3 (patch) | |
tree | 38fe934cd4dde30d0e72abce67b473f0a6da5e46 /src/testlib/qtestaccessible.h | |
parent | ffde36c9a31c488eb327a86a7437a6aa3665b452 (diff) | |
download | qtbase-3f7741000ccf058212da26c7dc4ab4c8b4c9c0f3.tar.gz |
QTestAccessible: Clear objects in EventList when deleted
The list persists events, which reference objects. Those objects might
get deleted by the time we investigate the objects. We cannot change the
event to store a QPointer for BIC reasons, and for normal usage of the
events, that doesn't make sense either.
Instead, connect the objects destroyed signal to a lambda which clears
the events' object member.
In order to access the private member, we befriend the test class.
Change-Id: I036be7053dccde4bdf862173789564e89d729ee1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/testlib/qtestaccessible.h')
-rw-r--r-- | src/testlib/qtestaccessible.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/testlib/qtestaccessible.h b/src/testlib/qtestaccessible.h index bd77ee77a1..8fe5fba338 100644 --- a/src/testlib/qtestaccessible.h +++ b/src/testlib/qtestaccessible.h @@ -185,7 +185,16 @@ private: static void updateHandler(QAccessibleEvent *event) { - eventList().append(copyEvent(event)); + auto ev = copyEvent(event); + if (ev->object()) { + QObject::connect(ev->object(), &QObject::destroyed, [&, ev](){ + auto index= eventList().indexOf(ev); + if (index == -1) + return; + eventList().at(index)->m_object = nullptr; + }); + } + eventList().append(ev); } static QAccessibleEvent *copyEvent(QAccessibleEvent *event) { |