Use QList instead of QVector in dbus
Omitted type replacement in qDBusParametersForMethod() for now. Task-number: QTBUG-84469 Change-Id: Ieb9fbb30b431c5e4183ad57acd35640e9556bf6c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
0475460102
commit
48c8322a61
@ -305,7 +305,7 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
|
||||
realObject = realObject->parent();
|
||||
|
||||
// break down the parameter list
|
||||
QVector<int> types;
|
||||
QList<int> types;
|
||||
QString errorMsg;
|
||||
int inputCount = qDBusParametersForMethod(mm, types, errorMsg);
|
||||
if (inputCount == -1) {
|
||||
|
@ -55,11 +55,11 @@
|
||||
#include <QtDBus/private/qtdbusglobal_p.h>
|
||||
#include <qdbusabstractadaptor.h>
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qmap.h>
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qreadwritelock.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtCore/qvector.h>
|
||||
#include "private/qobject_p.h"
|
||||
|
||||
#define QCLASSINFO_DBUS_INTERFACE "D-Bus Interface"
|
||||
@ -107,7 +107,7 @@ public: // typedefs
|
||||
inline bool operator<(const QByteArray &other) const
|
||||
{ return interface < other; }
|
||||
};
|
||||
typedef QVector<AdaptorData> AdaptorMap;
|
||||
typedef QList<AdaptorData> AdaptorMap;
|
||||
|
||||
public: // methods
|
||||
explicit QDBusAdaptorConnector(QObject *parent);
|
||||
|
@ -247,8 +247,8 @@ bool QDBusArgumentPrivate::checkReadAndDetach(QDBusArgumentPrivate *&d)
|
||||
|
||||
\value VariantType The variant element (QDBusVariant)
|
||||
|
||||
\value ArrayType An array element, usually represented by QList<T>
|
||||
or QVector<T>. Note: QByteArray and associative maps are not
|
||||
\value ArrayType An array element, usually represented by QList<T>.
|
||||
Note: QByteArray and associative maps are not
|
||||
considered arrays, even if the D-Bus protocol transports them as such.
|
||||
|
||||
\value StructureType A custom type represented by a structure,
|
||||
@ -869,7 +869,7 @@ void QDBusArgument::endStructure()
|
||||
|
||||
\snippet code/src_qdbus_qdbusargument.cpp 6
|
||||
|
||||
If the type you want to marshall is a QList, QVector or any of the
|
||||
If the type you want to marshall is a QList or any of the
|
||||
Qt's \l {Container Classes} that take one template parameter,
|
||||
you need not declare an \c{operator<<} function for it, since
|
||||
Qt D-Bus provides generic templates to do the job of marshalling
|
||||
@ -997,7 +997,7 @@ void QDBusArgument::endStructure() const
|
||||
|
||||
\snippet code/src_qdbus_qdbusargument.cpp 9
|
||||
|
||||
If the type you want to demarshall is a QList, QVector or any of the
|
||||
If the type you want to demarshall is a QList or any of the
|
||||
Qt's \l {Container Classes} that take one template parameter, you
|
||||
need not declare an \c{operator>>} function for it, since Qt D-Bus
|
||||
provides generic templates to do the job of demarshalling the data.
|
||||
|
@ -44,7 +44,6 @@
|
||||
#include <qdebug.h>
|
||||
#include <qcoreapplication.h>
|
||||
#include <qstringlist.h>
|
||||
#include <qvector.h>
|
||||
#include <qtimer.h>
|
||||
#include <qthread.h>
|
||||
#include <QtCore/private/qlocking_p.h>
|
||||
|
@ -59,12 +59,12 @@
|
||||
|
||||
#include <QtCore/qatomic.h>
|
||||
#include <QtCore/qhash.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
#include <QtCore/qreadwritelock.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/qvarlengtharray.h>
|
||||
#include <QtCore/qvector.h>
|
||||
|
||||
#include "qdbus_symbols_p.h"
|
||||
|
||||
@ -137,7 +137,7 @@ public:
|
||||
QString service, path, signature;
|
||||
QObject* obj;
|
||||
int midx;
|
||||
QVector<int> params;
|
||||
QList<int> params;
|
||||
ArgMatchRules argumentMatch;
|
||||
QByteArray matchRule;
|
||||
};
|
||||
@ -149,7 +149,7 @@ public:
|
||||
|
||||
struct ObjectTreeNode
|
||||
{
|
||||
typedef QVector<ObjectTreeNode> DataList;
|
||||
typedef QList<ObjectTreeNode> DataList;
|
||||
|
||||
inline ObjectTreeNode() : obj(nullptr), flags(0) { }
|
||||
inline ObjectTreeNode(const QString &n) // intentionally implicit
|
||||
@ -176,12 +176,12 @@ public:
|
||||
// typedefs
|
||||
typedef QMultiHash<qintptr, Watcher> WatcherHash;
|
||||
typedef QHash<int, DBusTimeout *> TimeoutHash;
|
||||
typedef QVector<QDBusMessage> PendingMessageList;
|
||||
typedef QList<QDBusMessage> PendingMessageList;
|
||||
|
||||
typedef QMultiHash<QString, SignalHook> SignalHookHash;
|
||||
typedef QHash<QString, QDBusMetaObject* > MetaObjectHash;
|
||||
typedef QHash<QByteArray, int> MatchRefCountHash;
|
||||
typedef QVector<QDBusPendingCallPrivate*> PendingCallList;
|
||||
typedef QList<QDBusPendingCallPrivate *> PendingCallList;
|
||||
|
||||
struct WatchedServiceData {
|
||||
WatchedServiceData() : refcount(0) {}
|
||||
@ -264,7 +264,7 @@ private:
|
||||
void sendInternal(QDBusPendingCallPrivate *pcall, void *msg, int timeout);
|
||||
void sendError(const QDBusMessage &msg, QDBusError::ErrorType code);
|
||||
void deliverCall(QObject *object, int flags, const QDBusMessage &msg,
|
||||
const QVector<int> &metaTypes, int slotIdx);
|
||||
const QList<int> &metaTypes, int slotIdx);
|
||||
|
||||
SignalHookHash::Iterator removeSignalHookNoLock(SignalHookHash::Iterator it);
|
||||
void collectAllObjects(ObjectTreeNode &node, QSet<QObject *> &set);
|
||||
@ -345,7 +345,7 @@ public:
|
||||
|
||||
public:
|
||||
// static methods
|
||||
static int findSlot(QObject *obj, const QByteArray &normalizedName, QVector<int> ¶ms);
|
||||
static int findSlot(QObject *obj, const QByteArray &normalizedName, QList<int> ¶ms);
|
||||
static bool prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key,
|
||||
const QString &service,
|
||||
const QString &path, const QString &interface, const QString &name,
|
||||
@ -354,7 +354,7 @@ public:
|
||||
bool buildSignature);
|
||||
static DBusHandlerResult messageFilter(DBusConnection *, DBusMessage *, void *);
|
||||
static QDBusCallDeliveryEvent *prepareReply(QDBusConnectionPrivate *target, QObject *object,
|
||||
int idx, const QVector<int> &metaTypes,
|
||||
int idx, const QList<int> &metaTypes,
|
||||
const QDBusMessage &msg);
|
||||
static void processFinishedCall(QDBusPendingCallPrivate *call);
|
||||
|
||||
@ -367,9 +367,11 @@ public:
|
||||
};
|
||||
|
||||
// in qdbusmisc.cpp
|
||||
extern int qDBusParametersForMethod(const QMetaMethod &mm, QVector<int> &metaTypes, QString &errorMsg);
|
||||
#endif // QT_BOOTSTRAPPED
|
||||
extern Q_DBUS_EXPORT int qDBusParametersForMethod(const QList<QByteArray> ¶meters, QVector<int>& metaTypes, QString &errorMsg);
|
||||
extern int qDBusParametersForMethod(const QMetaMethod &mm, QList<int> &metaTypes,
|
||||
QString &errorMsg);
|
||||
# endif // QT_BOOTSTRAPPED
|
||||
extern Q_DBUS_EXPORT int qDBusParametersForMethod(const QList<QByteArray> ¶meters,
|
||||
QList<int> &metaTypes, QString &errorMsg);
|
||||
extern Q_DBUS_EXPORT bool qDBusCheckAsyncTag(const char *tag);
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
extern bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name);
|
||||
|
@ -412,7 +412,7 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root,
|
||||
result = *node;
|
||||
else
|
||||
// there really is no object here
|
||||
// we're just looking at an unused space in the QVector
|
||||
// we're just looking at an unused space in the QList
|
||||
node = nullptr;
|
||||
}
|
||||
return node;
|
||||
@ -604,7 +604,8 @@ static void huntAndDestroy(QObject *needle, QDBusConnectionPrivate::ObjectTreeNo
|
||||
}
|
||||
}
|
||||
|
||||
static void huntAndUnregister(const QVector<QStringView> &pathComponents, int i, QDBusConnection::UnregisterMode mode,
|
||||
static void huntAndUnregister(const QList<QStringView> &pathComponents, int i,
|
||||
QDBusConnection::UnregisterMode mode,
|
||||
QDBusConnectionPrivate::ObjectTreeNode *node)
|
||||
{
|
||||
if (pathComponents.count() == i) {
|
||||
@ -666,7 +667,7 @@ static void huntAndEmit(DBusConnection *connection, DBusMessage *msg,
|
||||
}
|
||||
|
||||
static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
|
||||
const QString &signature_, QVector<int> &metaTypes)
|
||||
const QString &signature_, QList<int> &metaTypes)
|
||||
{
|
||||
QByteArray msgSignature = signature_.toLatin1();
|
||||
|
||||
@ -777,9 +778,9 @@ void QDBusConnectionPrivate::setDispatchEnabled(bool enable)
|
||||
|
||||
static QDBusCallDeliveryEvent * const DIRECT_DELIVERY = (QDBusCallDeliveryEvent *)1;
|
||||
|
||||
QDBusCallDeliveryEvent* QDBusConnectionPrivate::prepareReply(QDBusConnectionPrivate *target,
|
||||
QDBusCallDeliveryEvent *QDBusConnectionPrivate::prepareReply(QDBusConnectionPrivate *target,
|
||||
QObject *object, int idx,
|
||||
const QVector<int> &metaTypes,
|
||||
const QList<int> &metaTypes,
|
||||
const QDBusMessage &msg)
|
||||
{
|
||||
Q_ASSERT(object);
|
||||
@ -915,7 +916,7 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu
|
||||
}
|
||||
|
||||
void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const QDBusMessage &msg,
|
||||
const QVector<int> &metaTypes, int slotIdx)
|
||||
const QList<int> &metaTypes, int slotIdx)
|
||||
{
|
||||
Q_ASSERT_X(!object || QThread::currentThread() == object->thread(),
|
||||
"QDBusConnection: internal threading error",
|
||||
@ -1303,8 +1304,8 @@ void QDBusConnectionPrivate::serviceOwnerChangedNoLock(const QString &name,
|
||||
it->owner = newOwner;
|
||||
}
|
||||
|
||||
int QDBusConnectionPrivate::findSlot(QObject* obj, const QByteArray &normalizedName,
|
||||
QVector<int> ¶ms)
|
||||
int QDBusConnectionPrivate::findSlot(QObject *obj, const QByteArray &normalizedName,
|
||||
QList<int> ¶ms)
|
||||
{
|
||||
int midx = obj->metaObject()->indexOfMethod(normalizedName);
|
||||
if (midx == -1)
|
||||
@ -2410,7 +2411,7 @@ void QDBusConnectionPrivate::registerObject(const ObjectTreeNode *node)
|
||||
void QDBusConnectionPrivate::unregisterObject(const QString &path, QDBusConnection::UnregisterMode mode)
|
||||
{
|
||||
QDBusConnectionPrivate::ObjectTreeNode *node = &rootNode;
|
||||
QVector<QStringView> pathComponents;
|
||||
QList<QStringView> pathComponents;
|
||||
int i;
|
||||
if (path == QLatin1String("/")) {
|
||||
i = 0;
|
||||
|
@ -84,7 +84,7 @@ struct QDBusSlotCache
|
||||
{
|
||||
int flags;
|
||||
int slotIdx;
|
||||
QVector<int> metaTypes;
|
||||
QList<int> metaTypes;
|
||||
|
||||
void swap(Data &other) noexcept
|
||||
{
|
||||
@ -105,9 +105,15 @@ class QDBusCallDeliveryEvent: public QAbstractMetaCallEvent
|
||||
{
|
||||
public:
|
||||
QDBusCallDeliveryEvent(const QDBusConnection &c, int id, QObject *sender,
|
||||
const QDBusMessage &msg, const QVector<int> &types, int f = 0)
|
||||
: QAbstractMetaCallEvent(sender, -1), connection(c), message(msg), metaTypes(types), id(id), flags(f)
|
||||
{ }
|
||||
const QDBusMessage &msg, const QList<int> &types, int f = 0)
|
||||
: QAbstractMetaCallEvent(sender, -1),
|
||||
connection(c),
|
||||
message(msg),
|
||||
metaTypes(types),
|
||||
id(id),
|
||||
flags(f)
|
||||
{
|
||||
}
|
||||
|
||||
void placeMetaCall(QObject *object) override
|
||||
{
|
||||
@ -117,7 +123,7 @@ public:
|
||||
private:
|
||||
QDBusConnection connection; // just for refcounting
|
||||
QDBusMessage message;
|
||||
QVector<int> metaTypes;
|
||||
QList<int> metaTypes;
|
||||
int id;
|
||||
int flags;
|
||||
};
|
||||
|
@ -52,12 +52,12 @@
|
||||
//
|
||||
|
||||
#include <QtDBus/private/qtdbusglobal_p.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qvector.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qmap.h>
|
||||
#include <QtCore/qpair.h>
|
||||
#include <QtCore/qshareddata.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
@ -77,7 +77,7 @@ public:
|
||||
|
||||
// typedefs
|
||||
typedef QMap<QString, QString> Annotations;
|
||||
typedef QVector<Argument> Arguments;
|
||||
typedef QList<Argument> Arguments;
|
||||
typedef QMultiMap<QString, Method> Methods;
|
||||
typedef QMultiMap<QString, Signal> Signals;
|
||||
typedef QMap<QString, Property> Properties;
|
||||
|
@ -45,8 +45,8 @@
|
||||
|
||||
#include <qbytearray.h>
|
||||
#include <qglobal.h>
|
||||
#include <qlist.h>
|
||||
#include <qreadwritelock.h>
|
||||
#include <qvector.h>
|
||||
|
||||
#include "qdbusargument_p.h"
|
||||
#include "qdbusutil_p.h"
|
||||
@ -131,25 +131,13 @@ void QDBusMetaTypeId::init()
|
||||
qDBusRegisterMetaType<QList<QDBusObjectPath> >();
|
||||
qDBusRegisterMetaType<QList<QDBusSignature> >();
|
||||
qDBusRegisterMetaType<QList<QDBusUnixFileDescriptor> >();
|
||||
|
||||
qDBusRegisterMetaType<QVector<bool> >();
|
||||
qDBusRegisterMetaType<QVector<short> >();
|
||||
qDBusRegisterMetaType<QVector<ushort> >();
|
||||
qDBusRegisterMetaType<QVector<int> >();
|
||||
qDBusRegisterMetaType<QVector<uint> >();
|
||||
qDBusRegisterMetaType<QVector<qlonglong> >();
|
||||
qDBusRegisterMetaType<QVector<qulonglong> >();
|
||||
qDBusRegisterMetaType<QVector<double> >();
|
||||
qDBusRegisterMetaType<QVector<QDBusObjectPath> >();
|
||||
qDBusRegisterMetaType<QVector<QDBusSignature> >();
|
||||
qDBusRegisterMetaType<QVector<QDBusUnixFileDescriptor> >();
|
||||
#endif
|
||||
|
||||
initialized.storeRelaxed(true);
|
||||
}
|
||||
}
|
||||
|
||||
Q_GLOBAL_STATIC(QVector<QDBusCustomTypeInfo>, customTypes)
|
||||
Q_GLOBAL_STATIC(QList<QDBusCustomTypeInfo>, customTypes)
|
||||
Q_GLOBAL_STATIC(QReadWriteLock, customTypesLock)
|
||||
|
||||
/*!
|
||||
@ -228,7 +216,7 @@ Q_GLOBAL_STATIC(QReadWriteLock, customTypesLock)
|
||||
void QDBusMetaType::registerMarshallOperators(int id, MarshallFunction mf,
|
||||
DemarshallFunction df)
|
||||
{
|
||||
QVector<QDBusCustomTypeInfo> *ct = customTypes();
|
||||
QList<QDBusCustomTypeInfo> *ct = customTypes();
|
||||
if (id < 0 || !mf || !df || !ct)
|
||||
return; // error!
|
||||
|
||||
@ -253,7 +241,7 @@ bool QDBusMetaType::marshall(QDBusArgument &arg, int id, const void *data)
|
||||
MarshallFunction mf;
|
||||
{
|
||||
QReadLocker locker(customTypesLock());
|
||||
QVector<QDBusCustomTypeInfo> *ct = customTypes();
|
||||
QList<QDBusCustomTypeInfo> *ct = customTypes();
|
||||
if (id >= ct->size())
|
||||
return false; // non-existent
|
||||
|
||||
@ -282,7 +270,7 @@ bool QDBusMetaType::demarshall(const QDBusArgument &arg, int id, void *data)
|
||||
DemarshallFunction df;
|
||||
{
|
||||
QReadLocker locker(customTypesLock());
|
||||
QVector<QDBusCustomTypeInfo> *ct = customTypes();
|
||||
QList<QDBusCustomTypeInfo> *ct = customTypes();
|
||||
if (id >= ct->size())
|
||||
return false; // non-existent
|
||||
|
||||
@ -456,7 +444,7 @@ const char *QDBusMetaType::typeToSignature(int type)
|
||||
return DBUS_TYPE_UNIX_FD_AS_STRING;
|
||||
|
||||
// try the database
|
||||
QVector<QDBusCustomTypeInfo> *ct = customTypes();
|
||||
QList<QDBusCustomTypeInfo> *ct = customTypes();
|
||||
{
|
||||
QReadLocker locker(customTypesLock());
|
||||
if (type >= ct->size())
|
||||
|
@ -41,14 +41,14 @@
|
||||
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qmetaobject.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
|
||||
#include "qdbusutil_p.h"
|
||||
#include "qdbusconnection_p.h"
|
||||
#include "qdbusabstractadaptor_p.h" // for QCLASSINFO_DBUS_*
|
||||
#endif
|
||||
#include <QtCore/qvector.h>
|
||||
#include "qdbusmetatype_p.h"
|
||||
|
||||
#ifndef QT_NO_DBUS
|
||||
@ -135,14 +135,15 @@ bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name)
|
||||
// metaTypes.count() >= retval + 1 in all cases
|
||||
//
|
||||
// sig must be the normalised signature for the method
|
||||
int qDBusParametersForMethod(const QMetaMethod &mm, QVector<int> &metaTypes, QString &errorMsg)
|
||||
int qDBusParametersForMethod(const QMetaMethod &mm, QList<int> &metaTypes, QString &errorMsg)
|
||||
{
|
||||
return qDBusParametersForMethod(mm.parameterTypes(), metaTypes, errorMsg);
|
||||
}
|
||||
|
||||
#endif // QT_BOOTSTRAPPED
|
||||
|
||||
int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QVector<int>& metaTypes, QString &errorMsg)
|
||||
int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QList<int> &metaTypes,
|
||||
QString &errorMsg)
|
||||
{
|
||||
QDBusMetaTypeId::init();
|
||||
metaTypes.clear();
|
||||
|
@ -54,10 +54,10 @@
|
||||
#define QDBUSPENDINGCALL_P_H
|
||||
|
||||
#include <QtDBus/private/qtdbusglobal_p.h>
|
||||
#include <qshareddata.h>
|
||||
#include <qpointer.h>
|
||||
#include <qvector.h>
|
||||
#include <qlist.h>
|
||||
#include <qmutex.h>
|
||||
#include <qpointer.h>
|
||||
#include <qshareddata.h>
|
||||
#include <qwaitcondition.h>
|
||||
|
||||
#include "qdbusmessage.h"
|
||||
@ -82,7 +82,7 @@ public:
|
||||
|
||||
// for the callback mechanism (see setReplyCallback and QDBusConnectionPrivate::sendWithReplyAsync)
|
||||
QPointer<QObject> receiver;
|
||||
QVector<int> metaTypes;
|
||||
QList<int> metaTypes;
|
||||
int methodIdx;
|
||||
|
||||
// }
|
||||
|
@ -41,8 +41,8 @@
|
||||
|
||||
#include "qdbus_symbols_p.h"
|
||||
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/qvector.h>
|
||||
|
||||
#include "qdbusargument.h"
|
||||
#include "qdbusunixfiledescriptor.h"
|
||||
|
@ -175,7 +175,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
|
||||
}
|
||||
|
||||
QList<QByteArray> names = mm.parameterNames();
|
||||
QVector<int> types;
|
||||
QList<int> types;
|
||||
QString errorMsg;
|
||||
int inputCount = qDBusParametersForMethod(mm, types, errorMsg);
|
||||
if (inputCount == -1) {
|
||||
|
@ -54,7 +54,6 @@
|
||||
#if QT_DEPRECATED_SINCE(5, 5)
|
||||
#include <QtCore/qhash.h>
|
||||
#endif
|
||||
#include <QtCore/qvector.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user