Add a timeout for KNS backends

This patch will mark as invalid any KNS backend that takes longer
than sixty seconds.

This is supposed to go into the 5.14 branch, but may also be
useful in general (perhaps with a longer timeout to avoid issues
in parts of the world with particularly slow internet connections).

Differential Revision:
parent 125dca7b
......@@ -135,6 +135,18 @@ KNSBackend::KNSBackend(QObject* parent, const QString& iconName, const QString &
connect(m_engine, &KNSCore::Engine::signalEntryDetailsLoaded, this, &KNSBackend::statusChanged);
connect(m_engine, &KNSCore::Engine::signalProvidersLoaded, this, &KNSBackend::fetchInstalled);
// This ensures we have something to track when checking after the initialization timeout
connect(this, &KNSBackend::initialized, this, [this](){ m_initialized = true; });
// If we have not initialized in 60 seconds, consider this KNS backend invalid
QTimer::singleShot(60000, this, [this](){
if(!m_initialized) {
markInvalid(i18n("Backend %1 took too long to initialize", m_displayName));
m_responsePending = false;
Q_EMIT searchFinished();
Q_EMIT availableForQueries();
const QVector<QPair<FilterType, QString>> filters = { {CategoryFilter, fileName } };
const QSet<QString> backendName = { name() };
m_displayName = group.readEntry("Name", QString());
......@@ -97,6 +97,7 @@ private:
QStringList m_categories;
QVector<Category*> m_rootCategories;
QString m_displayName;
bool m_initialized = false;
#endif // KNSBACKEND_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment