summaryrefslogtreecommitdiff
path: root/src/gui/accessible/qaccessible.h
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-01-03 17:18:40 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-02 14:32:25 +0200
commitb2ec0da95641d9cec006fa9699e6d082ad35db0b (patch)
treec6ceef7e1527b98f3eda33b6e525d65ee1d810a6 /src/gui/accessible/qaccessible.h
parent8dfe1385b5f05b7242802a72897258a63af1ca1d (diff)
downloadqtbase-b2ec0da95641d9cec006fa9699e6d082ad35db0b.tar.gz
Cache QAccessibleInterfaces.
Since there already is a one-to-one relationship between QObject and QAccessibleInterface it makes little sense to create and destroy the interfaces on each call to queryAccessibleInterface. Add a cache and keep created interfaces around for the lifetime of the corresponding QObject. This changes the memory management rules: accessible interfaces must no longer be deleted. If you get an QAccessibleIntrface pointer that pointer will stay valid as long as the corresponding QObject is not deleted. This also re-enables accessibility for Mac. We limit the range of the IDs so that they are useable for Windows directly. That means we can get rid of the event cache there. This is based on: Iebf2f374916fc70a9dd29e95f45a6444b85f6cee Change-Id: I9fe6531812c0dbc5b41101ac05830a6dd75e13a3 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/gui/accessible/qaccessible.h')
-rw-r--r--src/gui/accessible/qaccessible.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h
index 09e259c1d0..8447f34154 100644
--- a/src/gui/accessible/qaccessible.h
+++ b/src/gui/accessible/qaccessible.h
@@ -45,6 +45,7 @@
#ifndef QACCESSIBLE_H
#define QACCESSIBLE_H
+#include <QtCore/qdebug.h>
#include <QtCore/qglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qrect.h>
@@ -58,7 +59,6 @@
QT_BEGIN_NAMESPACE
-
class QAccessibleInterface;
class QAccessibleEvent;
class QWindow;
@@ -335,12 +335,20 @@ public:
typedef void(*UpdateHandler)(QAccessibleEvent *event);
typedef void(*RootObjectHandler)(QObject*);
+ typedef unsigned Id;
+
static void installFactory(InterfaceFactory);
static void removeFactory(InterfaceFactory);
static UpdateHandler installUpdateHandler(UpdateHandler);
static RootObjectHandler installRootObjectHandler(RootObjectHandler);
static QAccessibleInterface *queryAccessibleInterface(QObject *);
+ static Id uniqueId(QAccessibleInterface *iface);
+ static QAccessibleInterface *accessibleInterface(Id uniqueId);
+ static Id registerAccessibleInterface(QAccessibleInterface *iface);
+ static void deleteAccessibleInterface(Id uniqueId);
+
+
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED static inline void updateAccessibility(QObject *object, int child, Event reason);
#endif
@@ -360,6 +368,8 @@ private:
it is not supposed to be instantiated.
*/
QAccessible() {}
+
+ friend class QAccessibleCache;
};
Q_GUI_EXPORT bool operator==(const QAccessible::State &first, const QAccessible::State &second);
@@ -377,8 +387,10 @@ class QAccessibleTableCellInterface;
class Q_GUI_EXPORT QAccessibleInterface
{
+protected:
+ virtual ~QAccessibleInterface();
+
public:
- virtual ~QAccessibleInterface() {}
// check for valid pointers
virtual bool isValid() const = 0;
virtual QObject *object() const = 0;
@@ -431,7 +443,9 @@ public:
virtual void *interface_cast(QAccessible::InterfaceType)
{ return 0; }
-private:
+
+protected:
+ friend class QAccessibleCache;
};
class Q_GUI_EXPORT QAccessibleEvent