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>
This commit is contained in:
parent
ffde36c9a3
commit
3f7741000c
@ -715,6 +715,7 @@ protected:
|
||||
QAccessible::Id m_uniqueId;
|
||||
};
|
||||
|
||||
friend class QTestAccessibility;
|
||||
};
|
||||
|
||||
class Q_GUI_EXPORT QAccessibleStateChangeEvent :public QAccessibleEvent
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user