41 #include <QtCore/qdebug.h>
42 #include <QtCore/qloggingcategory.h>
44 #ifndef QT_NO_ACCESSIBILITY
58 static void cleanupAccessibleCache()
60 delete accessibleCache;
61 accessibleCache =
nullptr;
72 if (!accessibleCache) {
76 return accessibleCache;
89 while (idToInterface.
contains(lastUsedId)) {
92 if (lastUsedId == UINT_MAX - 1)
103 return idToInterface.
value(
id);
108 return interfaceToId.
value(iface);
115 for (
auto pair : objectToId.
values(
obj)) {
116 if (pair.second ==
mo) {
133 for (
auto pair : objectToId.
values(
obj)) {
134 if (pair.second ==
mo) {
149 Q_ASSERT_X(!interfaceToId.
contains(iface),
"",
"Accessible interface inserted into cache twice!");
158 idToInterface.
insert(
id, iface);
159 interfaceToId.
insert(iface,
id);
160 qCDebug(lcAccessibilityCache) <<
"insert - id:" <<
id <<
" iface:" << iface;
164 void QAccessibleCache::objectDestroyed(
QObject*
obj)
191 for (
auto pair : objectToId.
values(
obj)) {
193 Q_ASSERT_X(idToInterface.
contains(
id),
"",
"QObject with accessible interface deleted, where interface not in cache!");
201 qCDebug(lcAccessibilityCache) <<
"delete - id:" <<
id <<
" iface:" << iface;
204 interfaceToId.
take(iface);
212 removeCocoaElement(
id);
218 #include "moc_qaccessiblecache_p.cpp"
bool containsObject(QObject *obj) const
~QAccessibleCache() override
QAccessible::Id insert(QObject *object, QAccessibleInterface *iface) const
QAccessibleInterface * interfaceForId(QAccessible::Id id) const
void deleteInterface(QAccessible::Id id, QObject *obj=nullptr)
QAccessible::Id idForInterface(QAccessibleInterface *iface) const
static QAccessibleCache * instance()
QAccessible::Id idForObject(QObject *obj) const
The QAccessibleInterface class defines an interface that exposes information about accessible objects...
virtual QObject * object() const =0
QList< Key > keys() const
bool contains(const Key &key) const noexcept
T value(const Key &key) const noexcept
iterator insert(const Key &key, const T &value)
QList< T > values() const
qsizetype remove(const Key &key)
iterator insert(const Key &key, const T &value)
The QObject class is the base class of all Qt objects.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
void destroyed(QObject *=nullptr)
QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcAccessibilityCache, "qt.accessibility.cache")
void qAddPostRoutine(QtCleanUpFunction p)
#define qCDebug(category,...)
constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
#define Q_ASSERT_X(cond, x, msg)