From 51dcf82db5990dde9cf3e6b3132dfff2c129bee5 Mon Sep 17 00:00:00 2001 From: Eugene Popov Date: Thu, 21 Sep 2023 10:31:48 +0000 Subject: [PATCH] [plasmacalendarintegration] Fix selected regions are randomly reset to default Check whether we are reading the selected regions from the group we need. BUG: 472483 FIXED-IN: 5.27.9 (cherry picked from commit 72444337c24dac114765ff28768bd55f7e5018c5) --- plasmacalendarintegration/holidaysevents.cpp | 19 +++++++++---------- plasmacalendarintegration/holidaysevents.h | 1 - 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/plasmacalendarintegration/holidaysevents.cpp b/plasmacalendarintegration/holidaysevents.cpp index 1e632a602e..605c1bd214 100644 --- a/plasmacalendarintegration/holidaysevents.cpp +++ b/plasmacalendarintegration/holidaysevents.cpp @@ -7,18 +7,19 @@ #include "holidaysevents.h" #include -#include HolidaysEventsPlugin::HolidaysEventsPlugin(QObject *parent) : CalendarEvents::CalendarEventsPlugin(parent) { - KSharedConfig::Ptr m_config = KSharedConfig::openConfig(QStringLiteral("plasma_calendar_holiday_regions")); - const KConfigGroup regionsConfig = m_config->group("General"); - updateSettings(regionsConfig); + KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasma_calendar_holiday_regions"), KConfig::NoGlobals); + updateSettings(config->group("General")); - m_configWatcher = KConfigWatcher::create(m_config); - connect(m_configWatcher.get(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &config) { - updateSettings(config); + m_configWatcher = KConfigWatcher::create(config); + connect(m_configWatcher.get(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &configGroup) { + if (configGroup.name() != QLatin1String("General")) { + return; + } + updateSettings(configGroup); loadEventsForDateRange(m_lastStartDate, m_lastEndDate); }); } @@ -35,9 +36,7 @@ void HolidaysEventsPlugin::loadEventsForDateRange(const QDate &startDate, const return; } - m_lastData.clear(); QMultiHash data; - for (KHolidays::HolidayRegion *region : qAsConst(m_regions)) { const KHolidays::Holiday::List holidays = region->rawHolidays(startDate, endDate); @@ -61,7 +60,7 @@ void HolidaysEventsPlugin::loadEventsForDateRange(const QDate &startDate, const m_lastEndDate = endDate; m_lastData = data; - Q_EMIT dataReady(data); + Q_EMIT dataReady(m_lastData); } void HolidaysEventsPlugin::updateSettings(const KConfigGroup ®ionsConfig) diff --git a/plasmacalendarintegration/holidaysevents.h b/plasmacalendarintegration/holidaysevents.h index 93067049f8..1658d9d122 100644 --- a/plasmacalendarintegration/holidaysevents.h +++ b/plasmacalendarintegration/holidaysevents.h @@ -32,6 +32,5 @@ private: QDate m_lastEndDate; QList m_regions; QMultiHash m_lastData; - KSharedConfig::Ptr m_config; KConfigWatcher::Ptr m_configWatcher; }; -- GitLab