From 3c6bb0ed8bfc9a2c679f4154585a16e47275ad21 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 16 Jan 2013 19:41:49 +0800 Subject: Make the QtDBus object tree keep a count of active children The new member variable activeChildren shall contain the number of direct children that are active. This number differs from children.count() because the vector may contain empty entries that haven't been garbage-collected yet (obj == NULL and activeChildren == 0). When this count drops to zero, we know we can simply erase the vector of children. Change-Id: Ia20604d3fac852ea4a6e8862d934fbb936fa5e18 Reviewed-by: David Faure (KDE) --- src/dbus/qdbusconnection_p.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/dbus/qdbusconnection_p.h') diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 50307e2738..3beb258bd8 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -140,14 +140,16 @@ public: { typedef QVector DataList; - inline ObjectTreeNode() : obj(0), flags(0) { } + inline ObjectTreeNode() : obj(0), flags(0), activeChildren(0) { } inline ObjectTreeNode(const QString &n) // intentionally implicit - : name(n), obj(0), flags(0) { } + : name(n), obj(0), flags(0), activeChildren(0) { } inline ~ObjectTreeNode() { } inline bool operator<(const QString &other) const { return name < other; } inline bool operator<(const QStringRef &other) const { return QStringRef(&name) < other; } + inline bool isActive() const + { return obj || activeChildren; } QString name; union { @@ -155,6 +157,7 @@ public: QDBusVirtualObject *treeNode; }; int flags; + int activeChildren; DataList children; }; -- cgit v1.2.3