QtDBus: Garbage collect deleted objects now and then.
Fixes performance issues in apps which register and deregister objects very frequently (like nepomukstorage). Change-Id: Ib4ce8d65868f0e26cd45f1053e4b2f4c13528cfa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
00e0923e60
commit
ac9ab9703f
@ -2224,6 +2224,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*)),
|
||||
@ -2247,6 +2260,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,
|
||||
|
Loading…
Reference in New Issue
Block a user