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) --- tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/auto/dbus') diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index ffcc2ddcdc..3c08f8999c 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -1200,6 +1200,19 @@ void tst_QDBusConnection::registerVirtualObject() QVERIFY(!con.registerVirtualObject(path, &obj, QDBusConnection::SubPath)); QCOMPARE(con.objectRegisteredAt(path), static_cast(0)); } + + { + // Register object, make sure no SubPath handling object can be registered on a parent path. + // (same as above, but deeper) + QObject objectAtSubPath; + QVERIFY(con.registerObject(childChildPath, &objectAtSubPath)); + QCOMPARE(con.objectRegisteredAt(childChildPath), static_cast(&objectAtSubPath)); + + VirtualObject obj; + QVERIFY(!con.registerVirtualObject(path, &obj, QDBusConnection::SubPath)); + QCOMPARE(con.objectRegisteredAt(path), static_cast(0)); + } + QCOMPARE(con.objectRegisteredAt(path), static_cast(0)); QCOMPARE(con.objectRegisteredAt(childPath), static_cast(0)); QCOMPARE(con.objectRegisteredAt(childChildPath), static_cast(0)); -- cgit v1.2.3