summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIevgenii Meshcheriakov <[email protected]>2023-08-29 15:55:59 +0200
committerIevgenii Meshcheriakov <[email protected]>2023-09-11 00:32:40 +0200
commitdad421222c42a88cb633949108bfb3bb1072305b (patch)
tree1cf65f116432f17698edf340eadce15447c2be67
parent588700dbfa1ca6c10ab9bc615bd10d065dfb4b72 (diff)
QDBus: Use type-safe object tree node flags
Change-Id: I7078b11d19d7a6444a020e0d400efbaea22f84a8 Reviewed-by: Thiago Macieira <[email protected]>
-rw-r--r--src/dbus/qdbusconnection_p.h11
-rw-r--r--src/dbus/qdbusintegrator.cpp11
-rw-r--r--src/dbus/qdbusintegrator_p.h2
3 files changed, 14 insertions, 10 deletions
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h
index bf04da01ba6..eb2ae52475d 100644
--- a/src/dbus/qdbusconnection_p.h
+++ b/src/dbus/qdbusconnection_p.h
@@ -115,9 +115,11 @@ public:
{
typedef QList<ObjectTreeNode> DataList;
- inline ObjectTreeNode() : obj(nullptr), flags(0) { }
+ inline ObjectTreeNode() : obj(nullptr) { }
inline ObjectTreeNode(const QString &n) // intentionally implicit
- : name(n), obj(nullptr), flags(0) { }
+ : name(n), obj(nullptr)
+ {
+ }
inline bool operator<(const QString &other) const
{ return name < other; }
inline bool operator<(QStringView other) const
@@ -131,7 +133,7 @@ public:
QObject *obj;
QDBusVirtualObject *treeNode;
};
- int flags;
+ QDBusConnection::RegisterOptions flags;
DataList children;
};
@@ -223,7 +225,8 @@ private:
void activateSignal(const SignalHook& hook, const QDBusMessage &msg);
void activateObject(ObjectTreeNode &node, const QDBusMessage &msg, int pathStartPos);
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 sendError(const QDBusMessage &msg, QDBusError::ErrorType code);
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index ed5d424ae4c..2f572e7ba3c 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -590,7 +590,7 @@ static void huntAndDestroy(QObject *needle, QDBusConnectionPrivate::ObjectTreeNo
if (needle == haystack.obj) {
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) {
// found it
node->obj = nullptr;
- node->flags = 0;
+ node->flags = {};
if (mode == QDBusConnection::UnregisterTree) {
// clear the sub-tree as well
@@ -817,7 +817,8 @@ void QDBusConnectionPrivate::activateSignal(const QDBusConnectionPrivate::Signal
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
// to a slot on the object.
@@ -1042,7 +1043,7 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
connect(this, &QDBusConnectionPrivate::messageNeedsSending,
this, &QDBusConnectionPrivate::sendInternal);
- rootNode.flags = 0;
+ rootNode.flags = {};
// prepopulate watchedServices:
// we know that the owner of org.freedesktop.DBus is itself
@@ -1453,7 +1454,7 @@ void QDBusConnectionPrivate::activateObject(ObjectTreeNode &node, const QDBusMes
QDBusAdaptorConnector *connector;
if (node.flags & QDBusConnection::ExportAdaptors &&
(connector = qDBusFindAdaptorConnector(node.obj))) {
- int newflags = node.flags | QDBusConnection::ExportAllSlots;
+ auto newflags = node.flags | QDBusConnection::ExportAllSlots;
if (msg.interface().isEmpty()) {
// place the call in all interfaces
diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h
index 774fb79d0be..b0c349799ab 100644
--- a/src/dbus/qdbusintegrator_p.h
+++ b/src/dbus/qdbusintegrator_p.h
@@ -59,7 +59,7 @@ struct QDBusSlotCache
struct Key
{
QString memberWithSignature;
- int flags;
+ QDBusConnection::RegisterOptions flags;
friend bool operator==(const Key &lhs, const Key &rhs) noexcept
{