summaryrefslogtreecommitdiff
path: root/src/gui/accessible/qaccessible.h
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2022-08-26 14:51:04 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-08-27 03:38:16 +0000
commit0c0eadc484ab7143801593ccdbe8e96eeb9f6cf7 (patch)
treec2046c035d0535a0091b1711ccb18f44b7e9ebb7 /src/gui/accessible/qaccessible.h
parent063344c8b99d046be92fcbc2c631a79c59ad8a6e (diff)
downloadqtbase-0c0eadc484ab7143801593ccdbe8e96eeb9f6cf7.tar.gz
a11y: Prevent one case of losing a11y interface when setting event child
9a369a25ddfac9352cabde65c8476c7433dc6c3a added a QAccessibleEvent ctor that takes a QAccessibleInterface* instead of a QObject*. Retrieving the QAccessibleInterface* later is done using the interface's unique ID stored in the m_uniqueId member. However, the fact that m_uniqueId is a member of the union alongside with m_child means that setting a child via QAccessibleEvent::setChild also overwrites the stored unique ID, which breaks retrieving the accessible interface later. Fix this for the case where the QAccessibleInterface has an associated QObject by assigning m_object in the ctor as well. This means that a QAccessibleEvent created using either of the two constructors (the one taking the QObject* and the one taking the QAccessibleInterface* associated with the object) now behaves the same. Fixing the case where there is no associated QObject would require further changes (e.g. adding a member for the QAccessibleInterface* or making the m_uniqueId member a separate member instead of having it in a union with m_child). However, I see no way to do so without breaking the ABI, so that is left unchanged. This also adds a corresponding test case. Fixes: QTBUG-105988 Pick-to: 6.4 Change-Id: I71a548af0277a5034e9e207f066fa3e25c5393f3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/accessible/qaccessible.h')
-rw-r--r--src/gui/accessible/qaccessible.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h
index 2700b5c080..b5e155c01e 100644
--- a/src/gui/accessible/qaccessible.h
+++ b/src/gui/accessible/qaccessible.h
@@ -287,7 +287,7 @@ public:
}
inline QAccessibleEvent(QAccessibleInterface *iface, QAccessible::Event typ)
- : m_type(typ), m_object(nullptr)
+ : m_type(typ)
{
Q_ASSERT(iface);
Q_ASSERT(m_type != QAccessible::ValueChanged);
@@ -299,6 +299,7 @@ public:
Q_ASSERT(m_type != QAccessible::TextUpdated);
Q_ASSERT(m_type != QAccessible::TableModelChanged);
m_uniqueId = QAccessible::uniqueId(iface);
+ m_object = iface->object();
}
virtual ~QAccessibleEvent();