From 2361d30e4be04df9b9fe970fbb185ed3d9a9331d Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 9 Mar 2024 16:03:26 +0100 Subject: [PATCH] fix: compare settings before updating them (#5240) --- CHANGELOG.md | 1 + lib/settings | 2 +- src/common/ChatterinoSetting.hpp | 7 +++++-- src/controllers/logging/ChannelLog.cpp | 5 +++++ src/singletons/Settings.cpp | 6 +++++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e07661c88..95b51e5de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ - Bugfix: Fixed triple click on message also selecting moderation buttons. (#4961) - Bugfix: Fixed a freeze from a bad regex in _Ignores_. (#4965, #5126) - Bugfix: Fixed badge highlight changes not immediately being reflected. (#5110) +- Bugfix: Fixed emotes being reloaded when pressing "Cancel" in the settings dialog, causing a slowdown. (#5240) - Bugfix: Fixed some emotes not appearing when using _Ignores_. (#4965, #5126) - Bugfix: Fixed lookahead/-behind not working in _Ignores_. (#4965, #5126) - Bugfix: Fixed Image Uploader accidentally deleting images with some hosts when link resolver was enabled. (#4971) diff --git a/lib/settings b/lib/settings index 41ef7899b..ceac9c7e9 160000 --- a/lib/settings +++ b/lib/settings @@ -1 +1 @@ -Subproject commit 41ef7899b1cce35982f2dac600b2034375574f49 +Subproject commit ceac9c7e97d2d2b97f40ecd0b421e358d7525cbc diff --git a/src/common/ChatterinoSetting.hpp b/src/common/ChatterinoSetting.hpp index 2f5a0cac4..be3ebb8ff 100644 --- a/src/common/ChatterinoSetting.hpp +++ b/src/common/ChatterinoSetting.hpp @@ -13,13 +13,16 @@ class ChatterinoSetting : public pajlada::Settings::Setting { public: ChatterinoSetting(const std::string &path) - : pajlada::Settings::Setting(path) + : pajlada::Settings::Setting( + path, pajlada::Settings::SettingOption::CompareBeforeSet) { _registerSetting(this->getData()); } ChatterinoSetting(const std::string &path, const Type &defaultValue) - : pajlada::Settings::Setting(path, defaultValue) + : pajlada::Settings::Setting( + path, defaultValue, + pajlada::Settings::SettingOption::CompareBeforeSet) { _registerSetting(this->getData()); } diff --git a/src/controllers/logging/ChannelLog.cpp b/src/controllers/logging/ChannelLog.cpp index 2c163050b..67925b945 100644 --- a/src/controllers/logging/ChannelLog.cpp +++ b/src/controllers/logging/ChannelLog.cpp @@ -7,6 +7,11 @@ ChannelLog::ChannelLog(QString channelName) { } +bool ChannelLog::operator==(const ChannelLog &other) const +{ + return this->channelName_ == other.channelName_; +} + QString ChannelLog::channelName() const { return this->channelName_.toLower(); diff --git a/src/singletons/Settings.cpp b/src/singletons/Settings.cpp index b05c13409..451692aa0 100644 --- a/src/singletons/Settings.cpp +++ b/src/singletons/Settings.cpp @@ -9,6 +9,7 @@ #include "controllers/moderationactions/ModerationAction.hpp" #include "controllers/nicknames/Nickname.hpp" #include "debug/Benchmark.hpp" +#include "pajlada/settings/signalargs.hpp" #include "util/Clamp.hpp" #include "util/PersistSignalVector.hpp" #include "util/WindowsHelper.hpp" @@ -257,7 +258,10 @@ void Settings::restoreSnapshot() continue; } - setting->marshalJSON(snapshot[path]); + pajlada::Settings::SignalArgs args; + args.compareBeforeSet = true; + + setting->marshalJSON(snapshot[path], std::move(args)); } }