File 0023-fix-annoying-notifications-over-and-over.patch of Package apper

Git commit 0fedb139a16a89344ff3afcee1fa51d42ed48104 by Daniel Nicoletti.
Committed on 20/02/2013 at 15:28.
Pushed by dantti into branch 'master'.

Make sure we don't keep showing the same error over and over again...
FIXES: https://bugzilla.novell.com/show_bug.cgi?id=802562

M  +12   -5    apperd/RefreshCacheTask.cpp
M  +2    -0    apperd/RefreshCacheTask.h

http://commits.kde.org/apper/0fedb139a16a89344ff3afcee1fa51d42ed48104

diff --git a/apperd/RefreshCacheTask.cpp b/apperd/RefreshCacheTask.cpp
index e633643..518efe8 100644
--- a/apperd/RefreshCacheTask.cpp
+++ b/apperd/RefreshCacheTask.cpp
@@ -29,11 +29,10 @@
 
 #include <KDebug>
 
-using namespace PackageKit;
-
 RefreshCacheTask::RefreshCacheTask(QObject *parent) :
     QObject(parent),
-    m_transaction(0)
+    m_transaction(0),
+    m_lastError(Transaction::ErrorUnknown)
 {
 }
 
@@ -43,7 +42,7 @@ void RefreshCacheTask::refreshCache()
     if (!m_transaction) {
         m_transaction = new Transaction(this);
         connect(m_transaction, SIGNAL(finished(PackageKit::Transaction::Exit,uint)),
-                this, SLOT(refreshCacheFinished(PackageKit::Transaction::Exit)));
+                this, SLOT(refreshCacheFinished(PackageKit::Transaction::Exit,uint)));
         connect(m_transaction, SIGNAL(errorCode(PackageKit::Transaction::Error,QString)),
                 this, SLOT(errorCode(PackageKit::Transaction::Error,QString)));
 
@@ -67,13 +66,21 @@ void RefreshCacheTask::refreshCache()
 
 void RefreshCacheTask::refreshCacheFinished(PackageKit::Transaction::Exit status, uint runtime)
 {
-    Q_UNUSED(status)
     Q_UNUSED(runtime)
+
     m_transaction = 0;
+    if (status == Transaction::ExitSuccess) {
+        m_lastError = Transaction::ErrorUnknown;
+        m_lastErrorString.clear();
+    }
 }
 
 void RefreshCacheTask::errorCode(Transaction::Error error, const QString &errorMessage)
 {
+    if (m_lastError == error && m_lastErrorString == errorMessage) {
+        return;
+    }
+
     // Not decreasing and being Persistent
     // prevents multiple popups issued by
     // subsequent refresh cache tries
diff --git a/apperd/RefreshCacheTask.h b/apperd/RefreshCacheTask.h
index 7136bd2..c916792 100644
--- a/apperd/RefreshCacheTask.h
+++ b/apperd/RefreshCacheTask.h
@@ -43,6 +43,8 @@ private slots:
 private:
     KNotification *m_notification;
     Transaction *m_transaction;
+    Transaction::Error m_lastError;
+    QString m_lastErrorString;
 };
 
 #endif // REFRESHCACHETASK_H
openSUSE Build Service is sponsored by