Commit 356fe501 authored by Dan Leinir Turthra Jensen's avatar Dan Leinir Turthra Jensen 🌈

Fix crash in category comparison caused by incorrect filters

Prior to this, we would crash when attempting to create our own
Applications Category instance in KNSBackend. We can now set the
and filters programmatically and no longer crash. The patch
durther outputs the entirety of the comparison conditions we're
using, for easier debuggings.

Differential Revision: https://phabricator.kde.org/D19880
parent eccaa65c
......@@ -134,6 +134,11 @@ QVector<QPair<FilterType, QString> > Category::andFilters() const
return m_andFilters;
}
void Category::setAndFilter(QVector<QPair<FilterType, QString> > filters)
{
m_andFilters = filters;
}
QVector<QPair<FilterType, QString> > Category::orFilters() const
{
return m_orFilters;
......@@ -192,6 +197,7 @@ void Category::addSubcategory(QVector< Category* >& list, Category* newcat)
)
{
qCWarning(LIBDISCOVER_LOG) << "the following categories seem to be the same but they're not entirely"
<< c->icon() << newcat->icon() << "--"
<< c->name() << newcat->name() << "--"
<< c->andFilters() << newcat->andFilters() << "--"
<< c->isAddons() << newcat->isAddons();
......
......@@ -57,6 +57,7 @@ public:
QString name() const;
QString icon() const;
QVector<QPair<FilterType, QString> > andFilters() const;
void setAndFilter(QVector<QPair<FilterType, QString> > filters);
QVector<QPair<FilterType, QString> > orFilters() const;
QVector<QPair<FilterType, QString> > notFilters() const;
QVector<Category *> subCategories() const;
......
......@@ -156,7 +156,8 @@ KNSBackend::KNSBackend(QObject* parent, const QString& iconName, const QString &
if(knsrcApplications == fileName) {
m_hasApplications = true;
auto actualCategory = new Category(m_displayName, QStringLiteral("plasma"), filters, backendName, categories, QUrl(), false);
auto applicationCategory = new Category(i18n("Applications"), QStringLiteral("plasma"), filters, backendName, { actualCategory }, QUrl(), false);
auto applicationCategory = new Category(i18n("Applications"), QStringLiteral("applications-internet"), filters, backendName, { actualCategory }, QUrl(), false);
applicationCategory->setAndFilter({ {CategoryFilter, QLatin1String("Application")} });
m_categories.append(applicationCategory->name());
m_rootCategories = { applicationCategory };
// Make sure we filter out any apps which won't run on the current system architecture
......
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