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

List:       kde-commits
Subject:    KDE/kdepimlibs/akonadi
From:       Volker Krause <vkrause () kde ! org>
Date:       2010-12-27 9:46:35
Message-ID: 20101227094635.3C335AC8AD () svn ! kde ! org
[Download RAW message or body]

SVN commit 1209556 by vkrause:

Re-filter the pending notification when we notice that there is noone
listening to one of them. This can happen if the corresponding signal
has been disconnected in the meantime, which e.g. the recent
optimizations in AgentBase do.
Also, change the filtering from O(n ²) to O(n) while I was at it.


 M  +17 -11    monitor_p.cpp  


--- trunk/KDE/kdepimlibs/akonadi/monitor_p.cpp #1209555:1209556
@@ -217,18 +217,20 @@
 
 void MonitorPrivate::cleanOldNotifications()
 {
-  foreach ( const NotificationMessage &msg, pipeline ) {
-    if ( !acceptNotification( msg ) ) {
-      pipeline.removeOne( msg );
+  for ( NotificationMessage::List::iterator it = pipeline.begin(); it != \
pipeline.end(); ) { +    if ( !acceptNotification( *it ) )
+      it = pipeline.erase( it );
+    else
+      ++it;
     }
-  }
 
-  foreach ( const NotificationMessage &msg, pendingNotifications ) {
-    if ( !acceptNotification( msg ) ) {
-      pendingNotifications.removeOne( msg );
+  for ( NotificationMessage::List::iterator it = pendingNotifications.begin(); it != \
pendingNotifications.end(); ) { +    if ( !acceptNotification( *it ) )
+      it = pendingNotifications.erase( it );
+    else
+      ++it;
     }
   }
-}
 
 bool MonitorPrivate::ensureDataAvailable( const NotificationMessage &msg )
 {
@@ -259,15 +261,19 @@
   if ( msg.operation() == NotificationMessage::Move )
     destParent = collectionCache.retrieve( msg.parentDestCollection() );
 
+  bool someoneWasListening = false;
   if ( msg.type() == NotificationMessage::Collection ) {
     const Collection col = collectionCache.retrieve( msg.uid() );
-    return emitCollectionNotification( msg, col, parent, destParent );
+    someoneWasListening = emitCollectionNotification( msg, col, parent, destParent \
);  } else if ( msg.type() == NotificationMessage::Item ) {
     const Item item = itemCache.retrieve( msg.uid() );
-    return emitItemNotification( msg, item, parent, destParent );
+    someoneWasListening = emitItemNotification( msg, item, parent, destParent );
   }
 
-  return false; // nothing emitted
+  if ( !someoneWasListening )
+    cleanOldNotifications(); // probably someone disconnected a signal in the \
meantime, get rid of the no longer interesting stuff +
+  return someoneWasListening;
 }
 
 void MonitorPrivate::dataAvailable()


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

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