summaryrefslogtreecommitdiffstats
path: root/src/dbus/qdbusintegrator.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-09-16 13:49:26 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-09-16 14:52:40 +0200
commit8c6755aeec312ae771ef334fc863642514db3f7c (patch)
tree3ccec405ee35690bdb7def6c0a3c42866bd9adc2 /src/dbus/qdbusintegrator.cpp
parent104debb6627d71f5540bb2c3347ce56dddc63594 (diff)
parentc40a48af997f57caa0ecfca0b247837ba5b2f89b (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: src/corelib/tools/qstring.cpp Change-Id: Ifc6cd3a0f1cf14cc0fe6cf30afb0c7f40cfdbc3e
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r--src/dbus/qdbusintegrator.cpp41
1 files changed, 7 insertions, 34 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index e5f3fbdc53..d797fbfb99 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -587,46 +587,22 @@ bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg)
return false;
}
-static void garbageCollectChildren(QDBusConnectionPrivate::ObjectTreeNode &node)
-{
- int size = node.children.count();
- if (node.activeChildren == 0) {
- // easy case
- node.children.clear();
- } else if (size > node.activeChildren * 3 || (size > 20 && size * 2 > node.activeChildren * 3)) {
- // rewrite the vector, keeping only the active children
- // if the vector is large (> 20 items) and has one third of inactives
- // or if the vector is small and has two thirds of inactives.
- QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator end = node.children.end();
- QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = node.children.begin();
- QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator tgt = it;
- for ( ; it != end; ++it) {
- if (it->isActive())
- *tgt++ = qMove(*it);
- }
- ++tgt;
- node.children.erase(tgt, end);
- }
-}
-
static void huntAndDestroy(QObject *needle, QDBusConnectionPrivate::ObjectTreeNode &haystack)
{
QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = haystack.children.begin();
- QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator end = haystack.children.end();
- for ( ; it != end; ++it) {
- if (!it->isActive())
- continue;
+
+ while (it != haystack.children.end()) {
huntAndDestroy(needle, *it);
if (!it->isActive())
- --haystack.activeChildren;
+ it = haystack.children.erase(it);
+ else
+ it++;
}
if (needle == haystack.obj) {
haystack.obj = 0;
haystack.flags = 0;
}
-
- garbageCollectChildren(haystack);
}
static void huntAndUnregister(const QStringList &pathComponents, int i, QDBusConnection::UnregisterMode mode,
@@ -639,7 +615,6 @@ static void huntAndUnregister(const QStringList &pathComponents, int i, QDBusCon
if (mode == QDBusConnection::UnregisterTree) {
// clear the sub-tree as well
- node->activeChildren = 0;
node->children.clear(); // can't disconnect the objects because we really don't know if they can
// be found somewhere else in the path too
}
@@ -648,14 +623,12 @@ static void huntAndUnregister(const QStringList &pathComponents, int i, QDBusCon
QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator end = node->children.end();
QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it =
std::lower_bound(node->children.begin(), end, pathComponents.at(i));
- if (it == end || it->name != pathComponents.at(i) || !it->isActive())
+ if (it == end || it->name != pathComponents.at(i))
return; // node not found
huntAndUnregister(pathComponents, i + 1, mode, it);
if (!it->isActive())
- --node->activeChildren;
-
- garbageCollectChildren(*node);
+ node->children.erase(it);
}
}