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

List:       kde-commits
Subject:    branches/KDE/4.2/kdebase/workspace/plasma/runners
From:       Jacopo De Simoi <wilderkde () gmail ! com>
Date:       2009-04-22 23:06:40
Message-ID: 1240441600.734127.27282.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 957823 by jacopods:

Backport the use of isValid() in runners; saves some good number of iterations when \
typing quickly.


 M  +12 -0     bookmarks/bookmarksrunner.cpp  
 M  +6 -19     nepomuksearch/nepomuksearchrunner.cpp  
 M  +4 -0      recentdocuments/recentdocuments.cpp  
 M  +21 -10    services/servicerunner.cpp  
 M  +4 -0      webshortcuts/webshortcutrunner.cpp  


--- branches/KDE/4.2/kdebase/workspace/plasma/runners/bookmarks/bookmarksrunner.cpp \
#957822:957823 @@ -61,6 +61,10 @@
 
     KBookmark bookmark = bookmarkGroup.first();
     while (!bookmark.isNull()) {
+        if (!context.isValid()) {
+            return;
+        }
+
         if (bookmark.isGroup()) { // descend
             //kDebug () << "descending into" << bookmark.text();
             groups.push(bookmarkGroup);
@@ -68,6 +72,10 @@
             bookmark = bookmarkGroup.first();
 
             while (bookmark.isNull() && !groups.isEmpty()) {
+                if (!context.isValid()) {
+                    return;
+                }
+
                 bookmark = bookmarkGroup;
                 bookmarkGroup = groups.pop();
                 bookmark = bookmarkGroup.next(bookmark);
@@ -113,6 +121,10 @@
 
         bookmark = bookmarkGroup.next(bookmark);
         while (bookmark.isNull() && !groups.isEmpty()) {
+            if (!context.isValid()) {
+                return;
+            }
+
             bookmark = bookmarkGroup;
             bookmarkGroup = groups.pop();
             //kDebug() << "ascending from" << bookmark.text() << "to" << \
                bookmarkGroup.text();
--- branches/KDE/4.2/kdebase/workspace/plasma/runners/nepomuksearch/nepomuksearchrunner.cpp \
#957822:957823 @@ -67,8 +67,6 @@
 
     // we are way less important than others, mostly because we are slow
     setPriority( LowPriority );
-
-    m_matchCnt = 0;
 }
 
 
@@ -89,29 +87,18 @@
     // in way too many queries for the rather sluggy Nepomuk query service
     // Thus, we use a little timeout to make sure we do not query too often
 
-    // we remember the match count when starting to wait, so we do not start the \
                query
-    // in case another call deprecated us (KRunner will simply rerun this method in \
                another
-    // thread when the user input changes)
-    int c = ++m_matchCnt;
+    m_waiter.wait(&m_mutex, s_userActionTimeout);
+    m_mutex.unlock();
 
-    kDebug() << &context << "waiting for match cnt" << c;
-
-    m_waiter.wait( &m_mutex, s_userActionTimeout );
-    if( c != m_matchCnt ) {
-        kDebug() << &context << "deprecated match cnt" << c;
+    if (!context.isValid()) {
+        kDebug() << "deprecated search";
         // we are no longer the latest call
-        m_mutex.unlock();
         return;
     }
 
-    kDebug() << &context << "running match cnt" << c;
-
-    m_mutex.unlock();
-
     // no queries on very short strings
-    if( Search::QueryServiceClient::serviceAvailable() &&
-        context.query().count() >= 3 ) {
-        QueryClientWrapper queryWrapper( this, &context );
+    if (Search::QueryServiceClient::serviceAvailable() && context.query().count() >= \
3) { +        QueryClientWrapper queryWrapper(this, &context);
         queryWrapper.runQuery();
         m_waiter.wakeAll();
     }
--- branches/KDE/4.2/kdebase/workspace/plasma/runners/recentdocuments/recentdocuments.cpp \
#957822:957823 @@ -67,6 +67,10 @@
     }
 
     foreach (const QString &document, m_recentdocuments) {
+        if (!context.isValid()) {
+            return;
+        }
+
         if (document.contains(term, Qt::CaseInsensitive)) {
             KConfig _config( document, KConfig::SimpleConfig );
             KConfigGroup config(&_config, "Desktop Entry" );
--- branches/KDE/4.2/kdebase/workspace/plasma/runners/services/servicerunner.cpp \
#957822:957823 @@ -59,18 +59,24 @@
     QHash<QString, bool> seen;
     if (!services.isEmpty()) {
         //kDebug() << service->name() << "is an exact match!" << \
                service->storageId() << service->exec();
-        KService::Ptr service = services.at(0);
-        if (!service->noDisplay()) {
-            Plasma::QueryMatch match(this);
-            match.setType(Plasma::QueryMatch::ExactMatch);
-            setupAction(service, match);
-            match.setRelevance(1);
-            matches << match;
-            seen[service->storageId()] = true;
-            seen[service->exec()] = true;
+        foreach (const KService::Ptr &service, services) {
+
+            if (!service->noDisplay()) {
+                Plasma::QueryMatch match(this);
+                match.setType(Plasma::QueryMatch::ExactMatch);
+                setupAction(service, match);
+                match.setRelevance(1);
+                matches << match;
+                seen[service->storageId()] = true;
+                seen[service->exec()] = true;
+            }
         }
     }
 
+    if (!context.isValid()) {
+        return;
+    }
+
     // Search for applications which are executable and the term case-insensitive \
matches any of  // * a substring of one of the keywords
     // * a substring of the GenericName field
@@ -83,6 +89,11 @@
 
     //kDebug() << "got " << services.count() << " services from " << query;
     foreach (const KService::Ptr &service, services) {
+
+     if (!context.isValid()) {
+        return;
+    }
+
         if (service->noDisplay()) {
             continue;
         }
@@ -139,7 +150,7 @@
             }
         }
 
-        //kDebug() << service->name() << "is this relevant:" << relevance;
+        //kDebug() << service->name() << "is this relevant:" << relevance << \
match.type();  match.setRelevance(relevance);
         matches << match;
     }
--- branches/KDE/4.2/kdebase/workspace/plasma/runners/webshortcuts/webshortcutrunner.cpp \
#957822:957823 @@ -86,6 +86,10 @@
     if (key != m_lastKey) {
         KService::List offers = serviceQuery("SearchProvider", QString("'%1' in \
Keys").arg(key));  
+        if (!context.isValid()) {
+            return;
+        }
+
         if (offers.isEmpty()) {
             m_lastFailedKey = key;
             return;


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

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