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) {
|
||||
// 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
|
||||
QList<QSpiObjectReference> related;
|
||||
QSpiObjectReferenceArray related;
|
||||
|
||||
QDBusObjectPath path = QDBusObjectPath(pathForInterface(pair.first));
|
||||
related.append(QSpiObjectReference(connection, path));
|
||||
|
|
|
@ -78,8 +78,7 @@ void QSpiDBusCache::emitRemoveAccessible(const QSpiObjectReference& item)
|
|||
|
||||
QSpiAccessibleCacheArray QSpiDBusCache::GetItems()
|
||||
{
|
||||
QList <QSpiAccessibleCacheItem> cacheArray;
|
||||
return cacheArray;
|
||||
return QSpiAccessibleCacheArray();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qvector.h>
|
||||
#include <QtCore/qpair.h>
|
||||
#include <QtDBus/QDBusArgument>
|
||||
#include <QtDBus/QDBusConnection>
|
||||
|
@ -55,8 +55,8 @@
|
|||
#ifndef QT_NO_ACCESSIBILITY
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
typedef QList <int> QSpiIntList;
|
||||
typedef QList <uint> QSpiUIntList;
|
||||
typedef QVector<int> QSpiIntList;
|
||||
typedef QVector<uint> QSpiUIntList;
|
||||
|
||||
// FIXME: make this copy on write
|
||||
struct QSpiObjectReference
|
||||
|
@ -68,26 +68,29 @@ struct QSpiObjectReference
|
|||
QSpiObjectReference(const QDBusConnection& connection, const QDBusObjectPath& 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);
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiObjectReference &address);
|
||||
|
||||
typedef QList <QSpiObjectReference> QSpiObjectReferenceArray;
|
||||
typedef QVector<QSpiObjectReference> QSpiObjectReferenceArray;
|
||||
|
||||
struct QSpiAccessibleCacheItem
|
||||
{
|
||||
QSpiObjectReference path;
|
||||
QSpiObjectReference application;
|
||||
QSpiObjectReference parent;
|
||||
QList <QSpiObjectReference> children;
|
||||
QSpiObjectReferenceArray children;
|
||||
QStringList supportedInterfaces;
|
||||
QString name;
|
||||
uint role;
|
||||
QString description;
|
||||
QSpiUIntList state;
|
||||
};
|
||||
Q_DECLARE_TYPEINFO(QSpiAccessibleCacheItem, Q_MOVABLE_TYPE);
|
||||
|
||||
typedef QList <QSpiAccessibleCacheItem> QSpiAccessibleCacheArray;
|
||||
typedef QVector<QSpiAccessibleCacheItem> QSpiAccessibleCacheArray;
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAccessibleCacheItem &item);
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAccessibleCacheItem &item);
|
||||
|
@ -98,8 +101,9 @@ struct QSpiAction
|
|||
QString description;
|
||||
QString keyBinding;
|
||||
};
|
||||
Q_DECLARE_TYPEINFO(QSpiAction, Q_MOVABLE_TYPE);
|
||||
|
||||
typedef QList <QSpiAction> QSpiActionArray;
|
||||
typedef QVector<QSpiAction> QSpiActionArray;
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAction &action);
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAction &action);
|
||||
|
@ -109,14 +113,15 @@ struct QSpiEventListener
|
|||
QString listenerAddress;
|
||||
QString eventName;
|
||||
};
|
||||
Q_DECLARE_TYPEINFO(QSpiEventListener, Q_MOVABLE_TYPE);
|
||||
|
||||
typedef QList <QSpiEventListener> QSpiEventListenerArray;
|
||||
typedef QVector<QSpiEventListener> QSpiEventListenerArray;
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiEventListener &action);
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiEventListener &action);
|
||||
|
||||
typedef QPair < unsigned int, QList < QSpiObjectReference > > QSpiRelationArrayEntry;
|
||||
typedef QList< QSpiRelationArrayEntry > QSpiRelationArray;
|
||||
typedef QPair<unsigned int, QSpiObjectReferenceArray> QSpiRelationArrayEntry;
|
||||
typedef QVector<QSpiRelationArrayEntry> QSpiRelationArray;
|
||||
|
||||
//a(iisv)
|
||||
struct QSpiTextRange {
|
||||
|
@ -125,18 +130,22 @@ struct QSpiTextRange {
|
|||
QString contents;
|
||||
QVariant v;
|
||||
};
|
||||
typedef QList <QSpiTextRange> QSpiTextRangeList;
|
||||
Q_DECLARE_TYPEINFO(QSpiTextRange, Q_MOVABLE_TYPE);
|
||||
|
||||
typedef QVector<QSpiTextRange> QSpiTextRangeList;
|
||||
typedef QMap <QString, QString> QSpiAttributeSet;
|
||||
|
||||
enum QSpiAppUpdateType {
|
||||
QSPI_APP_UPDATE_ADDED = 0,
|
||||
QSPI_APP_UPDATE_REMOVED = 1
|
||||
};
|
||||
Q_DECLARE_TYPEINFO(QSpiAppUpdateType, Q_PRIMITIVE_TYPE);
|
||||
|
||||
struct QSpiAppUpdate {
|
||||
int type; /* Is an 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);
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAppUpdate &update);
|
||||
|
@ -150,6 +159,7 @@ struct QSpiDeviceEvent {
|
|||
QString text;
|
||||
bool isText;
|
||||
};
|
||||
Q_DECLARE_TYPEINFO(QSpiDeviceEvent, Q_MOVABLE_TYPE);
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiDeviceEvent &event);
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiDeviceEvent &event);
|
||||
|
|
Loading…
Reference in New Issue