[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [knewstuff] src: Don't initialize KNS3::DownloadManager with the wrong categories
From: Aleix Pol <aleixpol () kde ! org>
Date: 2016-05-31 22:14:50
Message-ID: E1b7rw2-0000R2-K8 () scm ! kde ! org
[Download RAW message or body]
Git commit ed0a1be18ec5b421fc1319d2a28f118d9ea324b9 by Aleix Pol.
Committed on 31/05/2016 at 22:06.
Pushed by apol into branch 'master'.
Don't initialize KNS3::DownloadManager with the wrong categories
If we request some unexisting categories, we'll get basically a list of all
resources in the OCS server, which is not what we want.
For now, just emit an error instead so the front-end can react to it.
REVIEW: 128057
M +15 -2 src/attica/atticaprovider.cpp
M +2 -0 src/downloadmanager.cpp
M +5 -0 src/downloadmanager.h
http://commits.kde.org/knewstuff/ed0a1be18ec5b421fc1319d2a28f118d9ea324b9
diff --git a/src/attica/atticaprovider.cpp b/src/attica/atticaprovider.cpp
index 94f869e..69a7ca6 100644
--- a/src/attica/atticaprovider.cpp
+++ b/src/attica/atticaprovider.cpp
@@ -127,8 +127,21 @@ void AtticaProvider::listOfCategoriesLoaded(Attica::BaseJob *listJob)
mCategoryMap[category.name()] = category;
}
}
- mInitialized = true;
- emit providerInitialized(this);
+
+ bool correct = true;
+ for(auto it = mCategoryMap.cbegin(), itEnd = mCategoryMap.cend(); it!=itEnd; ++it) {
+ if (!it.value().isValid()) {
+ qCWarning(KNEWSTUFF) << "Could not find category" << it.key();
+ correct = false;
+ }
+ }
+
+ if (correct) {
+ mInitialized = true;
+ emit providerInitialized(this);
+ } else {
+ emit signalError(i18n("Some categories are missing"));
+ }
}
bool AtticaProvider::isInitialized() const
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 9eca302..8b6f960 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -95,6 +95,8 @@ DownloadManager::~DownloadManager()
void DownloadManagerPrivate::_k_slotEngineError(const QString &error)
{
qCWarning(KNEWSTUFF) << "engine error" << error;
+
+ Q_EMIT q->errorFound(error);
}
void DownloadManagerPrivate::_k_slotProvidersLoaded()
diff --git a/src/downloadmanager.h b/src/downloadmanager.h
index 0441742..39769f3 100644
--- a/src/downloadmanager.h
+++ b/src/downloadmanager.h
@@ -119,6 +119,11 @@ Q_SIGNALS:
*/
void entryStatusChanged(const KNS3::Entry &entry);
+ /**
+ * Notifies that the engine couldn't be loaded properly and won't be suitable
+ */
+ void errorFound(const QString &errorMessage);
+
private:
Q_PRIVATE_SLOT(d, void _k_slotProvidersLoaded())
Q_PRIVATE_SLOT(d, void _k_slotEngineError(const QString &error))
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic