[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kded
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2010-03-25 19:04:25
Message-ID: 20100325190425.968FEAC876 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1107474 by aseigo:

use QDBusServiceWatcher; now kded isn't woken up to do some processing every time a \
dbus service comes or goes, which is quite often


 M  +16 -11    kded.cpp  
 M  +6 -2      kded.h  


--- trunk/KDE/kdelibs/kded/kded.cpp #1107473:1107474
@@ -116,6 +116,12 @@
 {
   _self = this;
 
+  m_serviceWatcher = new QDBusServiceWatcher(this);
+  m_serviceWatcher->setConnection(QDBusConnection::sessionBus());
+  m_serviceWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
+  QObject::connect(m_serviceWatcher, SIGNAL(serviceUnregistered(QString)),
+                   this, SLOT(slotApplicationRemoved(QString)));
+
   new KBuildsycocaAdaptor(this);
   new KdedAdaptor(this);
 
@@ -413,8 +419,7 @@
   //   lib->unload();
 }
 
-void Kded::slotApplicationRemoved(const QString &name, const QString &oldOwner,
-                                  const QString &newOwner)
+void Kded::slotApplicationRemoved(const QString &name)
 {
 #if 0 // see kdedmodule.cpp (KDED_OBJECTS)
   foreach( KDEDModule* module, m_modules )
@@ -422,9 +427,7 @@
      module->removeAll(appId);
   }
 #endif
-  if (oldOwner.isEmpty() || !newOwner.isEmpty())
-     return;
-
+  m_serviceWatcher->removeWatchedService(name);
   const QList<qlonglong> windowIds = m_windowIdList.value(name);
   for( QList<qlonglong>::ConstIterator it = windowIds.begin();
        it != windowIds.end(); ++it)
@@ -632,6 +635,10 @@
 
 void Kded::registerWindowId(qlonglong windowId, const QString &sender)
 {
+  if (!m_windowIdList.contains(sender)) {
+      m_serviceWatcher->addWatchedService(sender);
+  }
+
   m_globalWindowIdList.insert(windowId);
   QList<qlonglong> windowIds = m_windowIdList.value(sender);
   windowIds.append(windowId);
@@ -651,10 +658,12 @@
   if (!windowIds.isEmpty())
   {
      windowIds.removeAll(windowId);
-     if (windowIds.isEmpty())
+     if (windowIds.isEmpty()) {
+        m_serviceWatcher->removeWatchedService(sender);
         m_windowIdList.remove(sender);
-     else
+     } else {
         m_windowIdList.insert(sender, windowIds);
+     }
   }
 
   foreach( KDEDModule* module, m_modules )
@@ -837,10 +846,6 @@
           if (bCheckHostname)
             (void) new KHostnameD(HostnamePollInterval); // Watch for hostname \
changes  
-          QObject::connect(QDBusConnection::sessionBus().interface(),
-                          SIGNAL(serviceOwnerChanged(QString,QString,QString)),
-                          kded, \
                SLOT(slotApplicationRemoved(QString,QString,QString)));
-
           kded->initModules();
        } else
           runBuildSycoca();
--- trunk/KDE/kdelibs/kded/kded.h #1107473:1107474
@@ -34,6 +34,7 @@
 #include <klibloader.h>
 #include <kservice.h>
 
+class QDBusServiceWatcher;
 class KDirWatch;
 
 // No need for this in libkio - apps only get readonly access
@@ -152,7 +153,7 @@
    /**
     * An application unregistered itself from DBus
     */
-   void slotApplicationRemoved(const QString&, const QString&, const QString&);
+   void slotApplicationRemoved(const QString&);
 
    /**
     * A KDEDModule is about to get destroyed.
@@ -200,9 +201,12 @@
    QHash<QString,KDEDModule *> m_modules;
     //QHash<QString,KLibrary *> m_libs;
    QHash<QString,QObject *> m_dontLoad;
+
+   //window id tracking, with a QDBusServiceWatcher to remove them as needed
+   QDBusServiceWatcher *m_serviceWatcher;
    QHash<QString,QList<qlonglong> > m_windowIdList;
+   QSet<long> m_globalWindowIdList;
 
-   QSet<long> m_globalWindowIdList;
    QStringList m_allResourceDirs;
    bool m_needDelayedCheck;
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic