summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/accessible/qaccessiblecache.cpp23
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp16
2 files changed, 37 insertions, 2 deletions
diff --git a/src/gui/accessible/qaccessiblecache.cpp b/src/gui/accessible/qaccessiblecache.cpp
index a8255e04c02..311b53aeaa3 100644
--- a/src/gui/accessible/qaccessiblecache.cpp
+++ b/src/gui/accessible/qaccessiblecache.cpp
@@ -4,6 +4,7 @@
#include "qaccessiblecache_p.h"
#include <QtCore/qdebug.h>
#include <QtCore/qloggingcategory.h>
+#include <private/qguiapplication_p.h>
#if QT_CONFIG(accessibility)
@@ -176,10 +177,28 @@ void QAccessibleCache::sendObjectDestroyedEvent(QObject *obj)
void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj)
{
- QAccessibleInterface *iface = idToInterface.take(id);
+ const auto it = idToInterface.find(id);
+ if (it == idToInterface.end()) // the interface may be deleted already
+ return;
+
+ QAccessibleInterface *iface = *it;
qCDebug(lcAccessibilityCache) << "delete - id:" << id << " iface:" << iface;
- if (!iface) // the interface may be deleted already
+ if (!iface) {
+ idToInterface.erase(it);
return;
+ }
+
+ // QObjects sends this from their destructor, but
+ // the object less interfaces calls deleteInterface
+ // directly
+ if (!obj && !iface->object()) {
+ if (QGuiApplicationPrivate::is_app_running && !QGuiApplicationPrivate::is_app_closing && QAccessible::isActive()) {
+ QAccessibleObjectDestroyedEvent event(id);
+ QAccessible::updateAccessibility(&event);
+ }
+ }
+
+ idToInterface.erase(it);
interfaceToId.take(iface);
if (!obj)
obj = iface->object();
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 305f48c95ee..c65f6645d01 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -3582,6 +3582,22 @@ void tst_QAccessibility::tableTest()
tableView->horizontalHeader()->setVisible(false);
}
+ {
+ QTestAccessibility::clearEvents();
+ auto cell0 = table2->cellAt(0, 2);
+ auto cell1 = table2->cellAt(1, 2);
+ auto cell2 = table2->cellAt(2, 2);
+ auto cell3 = table2->cellAt(3, 2);
+ QAccessibleObjectDestroyedEvent event0(cell0);
+ QAccessibleObjectDestroyedEvent event1(cell1);
+ QAccessibleObjectDestroyedEvent event2(cell2);
+ QAccessibleObjectDestroyedEvent event3(cell3);
+ tableView->removeColumn(2);
+ QVERIFY_EVENT(&event0);
+ QVERIFY_EVENT(&event1);
+ QVERIFY_EVENT(&event2);
+ QVERIFY_EVENT(&event3);
+ }
tvHolder.reset();
QVERIFY(!QAccessible::accessibleInterface(id00));
QTestAccessibility::clearEvents();