diff options
author | David Faure <faure@kde.org> | 2013-01-15 17:41:27 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-18 11:56:37 (GMT) |
commit | cf5442551196c3e7e06e6de85c5f8a198b0ff001 (patch) | |
tree | 594d1491df214a0fabaff0d049abf1ba23e4523d /src/dbus/qdbusintegrator.cpp | |
parent | 20b26bdb3dd5e46b01b9a7e1ce8342074df3c89c (diff) | |
download | Qt-cf5442551196c3e7e06e6de85c5f8a198b0ff001.zip Qt-cf5442551196c3e7e06e6de85c5f8a198b0ff001.tar.gz Qt-cf5442551196c3e7e06e6de85c5f8a198b0ff001.tar.bz2 |
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>
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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, |