QDBus: Use type-safe object tree node flags

Change-Id: I7078b11d19d7a6444a020e0d400efbaea22f84a8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ievgenii Meshcheriakov 2023-08-29 15:55:59 +02:00
parent 588700dbfa
commit dad421222c
3 changed files with 14 additions and 10 deletions

View File

@ -115,9 +115,11 @@ public:
{ {
typedef QList<ObjectTreeNode> DataList; typedef QList<ObjectTreeNode> DataList;
inline ObjectTreeNode() : obj(nullptr), flags(0) { } inline ObjectTreeNode() : obj(nullptr) { }
inline ObjectTreeNode(const QString &n) // intentionally implicit inline ObjectTreeNode(const QString &n) // intentionally implicit
: name(n), obj(nullptr), flags(0) { } : name(n), obj(nullptr)
{
}
inline bool operator<(const QString &other) const inline bool operator<(const QString &other) const
{ return name < other; } { return name < other; }
inline bool operator<(QStringView other) const inline bool operator<(QStringView other) const
@ -131,7 +133,7 @@ public:
QObject *obj; QObject *obj;
QDBusVirtualObject *treeNode; QDBusVirtualObject *treeNode;
}; };
int flags; QDBusConnection::RegisterOptions flags;
DataList children; DataList children;
}; };
@ -223,7 +225,8 @@ private:
void activateSignal(const SignalHook& hook, const QDBusMessage &msg); void activateSignal(const SignalHook& hook, const QDBusMessage &msg);
void activateObject(ObjectTreeNode &node, const QDBusMessage &msg, int pathStartPos); void activateObject(ObjectTreeNode &node, const QDBusMessage &msg, int pathStartPos);
bool activateInternalFilters(const ObjectTreeNode &node, const QDBusMessage &msg); bool activateInternalFilters(const ObjectTreeNode &node, const QDBusMessage &msg);
bool activateCall(QObject *object, int flags, const QDBusMessage &msg); bool activateCall(QObject *object, QDBusConnection::RegisterOptions flags,
const QDBusMessage &msg);
void sendInternal(QDBusPendingCallPrivate *pcall, void *msg, int timeout); void sendInternal(QDBusPendingCallPrivate *pcall, void *msg, int timeout);
void sendError(const QDBusMessage &msg, QDBusError::ErrorType code); void sendError(const QDBusMessage &msg, QDBusError::ErrorType code);

View File

@ -590,7 +590,7 @@ static void huntAndDestroy(QObject *needle, QDBusConnectionPrivate::ObjectTreeNo
if (needle == haystack.obj) { if (needle == haystack.obj) {
haystack.obj = nullptr; haystack.obj = nullptr;
haystack.flags = 0; haystack.flags = {};
} }
} }
@ -601,7 +601,7 @@ static void huntAndUnregister(const QList<QStringView> &pathComponents, int i,
if (pathComponents.size() == i) { if (pathComponents.size() == i) {
// found it // found it
node->obj = nullptr; node->obj = nullptr;
node->flags = 0; node->flags = {};
if (mode == QDBusConnection::UnregisterTree) { if (mode == QDBusConnection::UnregisterTree) {
// clear the sub-tree as well // clear the sub-tree as well
@ -817,7 +817,8 @@ void QDBusConnectionPrivate::activateSignal(const QDBusConnectionPrivate::Signal
postEventToThread(ActivateSignalAction, hook.obj, call); postEventToThread(ActivateSignalAction, hook.obj, call);
} }
bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBusMessage &msg) bool QDBusConnectionPrivate::activateCall(QObject *object, QDBusConnection::RegisterOptions flags,
const QDBusMessage &msg)
{ {
// This is called by QDBusConnectionPrivate::handleObjectCall to place a call // This is called by QDBusConnectionPrivate::handleObjectCall to place a call
// to a slot on the object. // to a slot on the object.
@ -1042,7 +1043,7 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
connect(this, &QDBusConnectionPrivate::messageNeedsSending, connect(this, &QDBusConnectionPrivate::messageNeedsSending,
this, &QDBusConnectionPrivate::sendInternal); this, &QDBusConnectionPrivate::sendInternal);
rootNode.flags = 0; rootNode.flags = {};
// prepopulate watchedServices: // prepopulate watchedServices:
// we know that the owner of org.freedesktop.DBus is itself // we know that the owner of org.freedesktop.DBus is itself
@ -1453,7 +1454,7 @@ void QDBusConnectionPrivate::activateObject(ObjectTreeNode &node, const QDBusMes
QDBusAdaptorConnector *connector; QDBusAdaptorConnector *connector;
if (node.flags & QDBusConnection::ExportAdaptors && if (node.flags & QDBusConnection::ExportAdaptors &&
(connector = qDBusFindAdaptorConnector(node.obj))) { (connector = qDBusFindAdaptorConnector(node.obj))) {
int newflags = node.flags | QDBusConnection::ExportAllSlots; auto newflags = node.flags | QDBusConnection::ExportAllSlots;
if (msg.interface().isEmpty()) { if (msg.interface().isEmpty()) {
// place the call in all interfaces // place the call in all interfaces

View File

@ -59,7 +59,7 @@ struct QDBusSlotCache
struct Key struct Key
{ {
QString memberWithSignature; QString memberWithSignature;
int flags; QDBusConnection::RegisterOptions flags;
friend bool operator==(const Key &lhs, const Key &rhs) noexcept friend bool operator==(const Key &lhs, const Key &rhs) noexcept
{ {