Commit a3dd72f4 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

Delay subCategoriesChanged signals when disabling

They can trigger a lot of JS code that induce lockups

BUG: 401666
BUG: 457408


(cherry picked from commit b704933b)
parent c237403e
Pipeline #247239 passed with stage
in 1 minute and 55 seconds
......@@ -7,6 +7,7 @@
#include "Category.h"
#include <QDomNode>
#include <QTimer>
#include "libdiscover_debug.h"
#include <KLocalizedString>
......@@ -19,6 +20,12 @@ Category::Category(QSet<QString> pluginName, QObject *parent)
, m_iconString(QStringLiteral("applications-other"))
, m_plugins(std::move(pluginName))
{
// Use a timer so to compress the rootCategoriesChanged signal
// It generally triggers when KNS is unavailable at large (as explained in bug 454442)
m_subCategoriesChanged = new QTimer(this);
m_subCategoriesChanged->setInterval(0);
m_subCategoriesChanged->setSingleShot(true);
connect(m_subCategoriesChanged, &QTimer::timeout, this, &Category::subCategoriesChanged);
}
Category::Category(const QString &name,
......@@ -36,6 +43,13 @@ Category::Category(const QString &name,
, m_isAddons(isAddons)
{
setObjectName(m_name);
// Use a timer so to compress the rootCategoriesChanged signal
// It generally triggers when KNS is unavailable at large (as explained in bug 454442)
m_subCategoriesChanged = new QTimer(this);
m_subCategoriesChanged->setInterval(0);
m_subCategoriesChanged->setSingleShot(true);
connect(m_subCategoriesChanged, &QTimer::timeout, this, &Category::subCategoriesChanged);
}
Category::~Category() = default;
......@@ -232,8 +246,9 @@ bool Category::blacklistPlugins(const QSet<QString> &pluginNames)
return true;
}
if (blacklistPluginsInVector(pluginNames, m_subCategories))
Q_EMIT subCategoriesChanged();
if (blacklistPluginsInVector(pluginNames, m_subCategories)) {
m_subCategoriesChanged->start();
}
return false;
}
......
......@@ -16,6 +16,7 @@
#include "discovercommon_export.h"
class QDomNode;
class QTimer;
enum FilterType {
InvalidFilter,
......@@ -93,6 +94,7 @@ private:
QVector<QPair<FilterType, QString>> parseIncludes(const QDomNode &data);
QSet<QString> m_plugins;
bool m_isAddons = false;
QTimer *m_subCategoriesChanged;
};
#endif
Supports Markdown
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