From kde-commits Tue May 31 22:14:50 2016 From: Aleix Pol Date: Tue, 31 May 2016 22:14:50 +0000 To: kde-commits Subject: [knewstuff] src: Don't initialize KNS3::DownloadManager with the wrong categories Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=146473289816896 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::Ba= seJob *listJob) mCategoryMap[category.name()] =3D category; } } - mInitialized =3D true; - emit providerInitialized(this); + + bool correct =3D true; + for(auto it =3D mCategoryMap.cbegin(), itEnd =3D mCategoryMap.cend(); = it!=3DitEnd; ++it) { + if (!it.value().isValid()) { + qCWarning(KNEWSTUFF) << "Could not find category" << it.key(); + correct =3D false; + } + } + + if (correct) { + mInitialized =3D 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 s= uitable + */ + void errorFound(const QString &errorMessage); + private: Q_PRIVATE_SLOT(d, void _k_slotProvidersLoaded()) Q_PRIVATE_SLOT(d, void _k_slotEngineError(const QString &error))