54 lines
1.8 KiB
Diff
54 lines
1.8 KiB
Diff
From cf5442551196c3e7e06e6de85c5f8a198b0ff001 Mon Sep 17 00:00:00 2001
|
|
From: David Faure <faure@kde.org>
|
|
Date: Tue, 15 Jan 2013 18:41:27 +0100
|
|
Subject: [PATCH 124/246] QtDBus: Garbage collect deleted objects now and then.
|
|
|
|
Fixes performance issues in apps which register and deregister objects
|
|
very frequently (like nepomukstorage).
|
|
|
|
Change-Id: Id7d6ef508336758c55fa894868241f143b3e30e0
|
|
Backport-Of: ac9ab9703ff299c94dca7585d5a12ecde28931bb
|
|
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
|
|
---
|
|
src/dbus/qdbusintegrator.cpp | 17 +++++++++++++++++
|
|
1 file changed, 17 insertions(+)
|
|
|
|
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
|
|
index f8bba28..96e4a12 100644
|
|
--- a/src/dbus/qdbusintegrator.cpp
|
|
+++ b/src/dbus/qdbusintegrator.cpp
|
|
@@ -2216,6 +2216,19 @@ QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it)
|
|
return signalHooks.erase(it);
|
|
}
|
|
|
|
+
|
|
+static void cleanupDeletedNodes(QDBusConnectionPrivate::ObjectTreeNode &parent)
|
|
+{
|
|
+ QMutableVectorIterator<QDBusConnectionPrivate::ObjectTreeNode> it(parent.children);
|
|
+ while (it.hasNext()) {
|
|
+ QDBusConnectionPrivate::ObjectTreeNode& node = it.next();
|
|
+ if (node.obj == 0 && node.children.isEmpty())
|
|
+ it.remove();
|
|
+ else
|
|
+ cleanupDeletedNodes(node);
|
|
+ }
|
|
+}
|
|
+
|
|
void QDBusConnectionPrivate::registerObject(const ObjectTreeNode *node)
|
|
{
|
|
connect(node->obj, SIGNAL(destroyed(QObject*)), SLOT(objectDestroyed(QObject*)),
|
|
@@ -2239,6 +2252,10 @@ void QDBusConnectionPrivate::registerObject(const ObjectTreeNode *node)
|
|
this, SLOT(relaySignal(QObject*,const QMetaObject*,int,QVariantList)),
|
|
Qt::DirectConnection);
|
|
}
|
|
+
|
|
+ static int counter = 0;
|
|
+ if ((++counter % 20) == 0)
|
|
+ cleanupDeletedNodes(rootNode);
|
|
}
|
|
|
|
void QDBusConnectionPrivate::connectRelay(const QString &service,
|
|
--
|
|
1.8.1.4
|
|
|