Fix deletion of items in QAccessibleCache
Items in the cache may be part of the parent/child hierarchy. Make sure not to have dangling pointers in the cache, but rather cleanly remove all interfaces that get deleted since they may delete each other (TabBar deletes its child interfaces for example. Task-number: QTBUG-69283 Change-Id: Iad17cd1d3356804b3d8cbba8632ec22b836c3521 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>bb10
parent
2a00a5d70b
commit
4fa12d8553
|
|
@ -59,8 +59,8 @@ static void cleanupAccessibleCache()
|
|||
|
||||
QAccessibleCache::~QAccessibleCache()
|
||||
{
|
||||
for (QAccessibleInterface *iface: idToInterface.values())
|
||||
delete iface;
|
||||
for (QAccessible::Id id: idToInterface.keys())
|
||||
deleteInterface(id);
|
||||
}
|
||||
|
||||
QAccessibleCache *QAccessibleCache::instance()
|
||||
|
|
@ -137,6 +137,8 @@ void QAccessibleCache::objectDestroyed(QObject* obj)
|
|||
void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj)
|
||||
{
|
||||
QAccessibleInterface *iface = idToInterface.take(id);
|
||||
if (!iface) // the interface may be deleted already
|
||||
return;
|
||||
interfaceToId.take(iface);
|
||||
if (!obj)
|
||||
obj = iface->object();
|
||||
|
|
|
|||
Loading…
Reference in New Issue