mirror of https://github.com/qt/qtbase.git
platformsupport/linuxaccessibility: fix uses of inefficient QLists
These types are larger than a void*, so holding them in QLists is needlessly inefficient. Worse, the code could come to depend on the fragile property of (inefficient) QLists that references to elements therein never are invalidated. Fix by marking them movable, and holding in a QVector instead. Change-Id: I3d5cf78c1597bd1b743ed3692aaa5e2e750a85f9 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
This commit is contained in:
parent
1477345990
commit
cd18e93845
|
@ -1509,7 +1509,7 @@ QSpiRelationArray AtSpiAdaptor::relationSet(QAccessibleInterface *interface, con
|
||||||
Q_FOREACH (const RelationPair &pair, relationInterfaces) {
|
Q_FOREACH (const RelationPair &pair, relationInterfaces) {
|
||||||
// FIXME: this loop seems a bit strange... "related" always have one item when we check.
|
// FIXME: this loop seems a bit strange... "related" always have one item when we check.
|
||||||
//And why is it a list, when it always have one item? And it seems to assume that the QAccessible::Relation enum maps directly to AtSpi
|
//And why is it a list, when it always have one item? And it seems to assume that the QAccessible::Relation enum maps directly to AtSpi
|
||||||
QList<QSpiObjectReference> related;
|
QSpiObjectReferenceArray related;
|
||||||
|
|
||||||
QDBusObjectPath path = QDBusObjectPath(pathForInterface(pair.first));
|
QDBusObjectPath path = QDBusObjectPath(pathForInterface(pair.first));
|
||||||
related.append(QSpiObjectReference(connection, path));
|
related.append(QSpiObjectReference(connection, path));
|
||||||
|
|
|
@ -78,8 +78,7 @@ void QSpiDBusCache::emitRemoveAccessible(const QSpiObjectReference& item)
|
||||||
|
|
||||||
QSpiAccessibleCacheArray QSpiDBusCache::GetItems()
|
QSpiAccessibleCacheArray QSpiDBusCache::GetItems()
|
||||||
{
|
{
|
||||||
QList <QSpiAccessibleCacheItem> cacheArray;
|
return QSpiAccessibleCacheArray();
|
||||||
return cacheArray;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
// We mean it.
|
// We mean it.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <QtCore/qlist.h>
|
#include <QtCore/qvector.h>
|
||||||
#include <QtCore/qpair.h>
|
#include <QtCore/qpair.h>
|
||||||
#include <QtDBus/QDBusArgument>
|
#include <QtDBus/QDBusArgument>
|
||||||
#include <QtDBus/QDBusConnection>
|
#include <QtDBus/QDBusConnection>
|
||||||
|
@ -55,8 +55,8 @@
|
||||||
#ifndef QT_NO_ACCESSIBILITY
|
#ifndef QT_NO_ACCESSIBILITY
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
typedef QList <int> QSpiIntList;
|
typedef QVector<int> QSpiIntList;
|
||||||
typedef QList <uint> QSpiUIntList;
|
typedef QVector<uint> QSpiUIntList;
|
||||||
|
|
||||||
// FIXME: make this copy on write
|
// FIXME: make this copy on write
|
||||||
struct QSpiObjectReference
|
struct QSpiObjectReference
|
||||||
|
@ -68,26 +68,29 @@ struct QSpiObjectReference
|
||||||
QSpiObjectReference(const QDBusConnection& connection, const QDBusObjectPath& path)
|
QSpiObjectReference(const QDBusConnection& connection, const QDBusObjectPath& path)
|
||||||
: service(connection.baseService()), path(path) {}
|
: service(connection.baseService()), path(path) {}
|
||||||
};
|
};
|
||||||
|
Q_DECLARE_TYPEINFO(QSpiObjectReference, Q_MOVABLE_TYPE); // QDBusObjectPath is movable, even though it
|
||||||
|
// cannot be marked that way until Qt 6
|
||||||
|
|
||||||
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiObjectReference &address);
|
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiObjectReference &address);
|
||||||
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiObjectReference &address);
|
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiObjectReference &address);
|
||||||
|
|
||||||
typedef QList <QSpiObjectReference> QSpiObjectReferenceArray;
|
typedef QVector<QSpiObjectReference> QSpiObjectReferenceArray;
|
||||||
|
|
||||||
struct QSpiAccessibleCacheItem
|
struct QSpiAccessibleCacheItem
|
||||||
{
|
{
|
||||||
QSpiObjectReference path;
|
QSpiObjectReference path;
|
||||||
QSpiObjectReference application;
|
QSpiObjectReference application;
|
||||||
QSpiObjectReference parent;
|
QSpiObjectReference parent;
|
||||||
QList <QSpiObjectReference> children;
|
QSpiObjectReferenceArray children;
|
||||||
QStringList supportedInterfaces;
|
QStringList supportedInterfaces;
|
||||||
QString name;
|
QString name;
|
||||||
uint role;
|
uint role;
|
||||||
QString description;
|
QString description;
|
||||||
QSpiUIntList state;
|
QSpiUIntList state;
|
||||||
};
|
};
|
||||||
|
Q_DECLARE_TYPEINFO(QSpiAccessibleCacheItem, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
typedef QList <QSpiAccessibleCacheItem> QSpiAccessibleCacheArray;
|
typedef QVector<QSpiAccessibleCacheItem> QSpiAccessibleCacheArray;
|
||||||
|
|
||||||
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAccessibleCacheItem &item);
|
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAccessibleCacheItem &item);
|
||||||
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAccessibleCacheItem &item);
|
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAccessibleCacheItem &item);
|
||||||
|
@ -98,8 +101,9 @@ struct QSpiAction
|
||||||
QString description;
|
QString description;
|
||||||
QString keyBinding;
|
QString keyBinding;
|
||||||
};
|
};
|
||||||
|
Q_DECLARE_TYPEINFO(QSpiAction, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
typedef QList <QSpiAction> QSpiActionArray;
|
typedef QVector<QSpiAction> QSpiActionArray;
|
||||||
|
|
||||||
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAction &action);
|
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAction &action);
|
||||||
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAction &action);
|
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAction &action);
|
||||||
|
@ -109,14 +113,15 @@ struct QSpiEventListener
|
||||||
QString listenerAddress;
|
QString listenerAddress;
|
||||||
QString eventName;
|
QString eventName;
|
||||||
};
|
};
|
||||||
|
Q_DECLARE_TYPEINFO(QSpiEventListener, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
typedef QList <QSpiEventListener> QSpiEventListenerArray;
|
typedef QVector<QSpiEventListener> QSpiEventListenerArray;
|
||||||
|
|
||||||
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiEventListener &action);
|
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiEventListener &action);
|
||||||
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiEventListener &action);
|
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiEventListener &action);
|
||||||
|
|
||||||
typedef QPair < unsigned int, QList < QSpiObjectReference > > QSpiRelationArrayEntry;
|
typedef QPair<unsigned int, QSpiObjectReferenceArray> QSpiRelationArrayEntry;
|
||||||
typedef QList< QSpiRelationArrayEntry > QSpiRelationArray;
|
typedef QVector<QSpiRelationArrayEntry> QSpiRelationArray;
|
||||||
|
|
||||||
//a(iisv)
|
//a(iisv)
|
||||||
struct QSpiTextRange {
|
struct QSpiTextRange {
|
||||||
|
@ -125,18 +130,22 @@ struct QSpiTextRange {
|
||||||
QString contents;
|
QString contents;
|
||||||
QVariant v;
|
QVariant v;
|
||||||
};
|
};
|
||||||
typedef QList <QSpiTextRange> QSpiTextRangeList;
|
Q_DECLARE_TYPEINFO(QSpiTextRange, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
|
typedef QVector<QSpiTextRange> QSpiTextRangeList;
|
||||||
typedef QMap <QString, QString> QSpiAttributeSet;
|
typedef QMap <QString, QString> QSpiAttributeSet;
|
||||||
|
|
||||||
enum QSpiAppUpdateType {
|
enum QSpiAppUpdateType {
|
||||||
QSPI_APP_UPDATE_ADDED = 0,
|
QSPI_APP_UPDATE_ADDED = 0,
|
||||||
QSPI_APP_UPDATE_REMOVED = 1
|
QSPI_APP_UPDATE_REMOVED = 1
|
||||||
};
|
};
|
||||||
|
Q_DECLARE_TYPEINFO(QSpiAppUpdateType, Q_PRIMITIVE_TYPE);
|
||||||
|
|
||||||
struct QSpiAppUpdate {
|
struct QSpiAppUpdate {
|
||||||
int type; /* Is an application added or removed */
|
int type; /* Is an application added or removed */
|
||||||
QString address; /* D-Bus address of application added or removed */
|
QString address; /* D-Bus address of application added or removed */
|
||||||
};
|
};
|
||||||
|
Q_DECLARE_TYPEINFO(QSpiAppUpdate, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAppUpdate &update);
|
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAppUpdate &update);
|
||||||
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAppUpdate &update);
|
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAppUpdate &update);
|
||||||
|
@ -150,6 +159,7 @@ struct QSpiDeviceEvent {
|
||||||
QString text;
|
QString text;
|
||||||
bool isText;
|
bool isText;
|
||||||
};
|
};
|
||||||
|
Q_DECLARE_TYPEINFO(QSpiDeviceEvent, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiDeviceEvent &event);
|
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiDeviceEvent &event);
|
||||||
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiDeviceEvent &event);
|
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiDeviceEvent &event);
|
||||||
|
|
Loading…
Reference in New Issue