fix: Fixed account switch not being saved if no other settings were changed (#5558)

This commit is contained in:
pajlada
2024-08-24 15:02:08 +02:00
committed by GitHub
parent aa048b3793
commit 9f588b7406
17 changed files with 69 additions and 73 deletions
+14 -2
View File
@@ -1,6 +1,7 @@
#include "singletons/Settings.hpp"
#include "Application.hpp"
#include "common/Args.hpp"
#include "controllers/filters/FilterRecord.hpp"
#include "controllers/highlights/HighlightBadge.hpp"
#include "controllers/highlights/HighlightBlacklistUser.hpp"
@@ -140,8 +141,9 @@ bool Settings::toggleMutedChannel(const QString &channelName)
Settings *Settings::instance_ = nullptr;
Settings::Settings(const QString &settingsDirectory)
Settings::Settings(const Args &args, const QString &settingsDirectory)
: prevInstance_(Settings::instance_)
, disableSaving(args.dontSaveSettings)
{
QString settingsPath = settingsDirectory + "/settings.json";
@@ -153,7 +155,7 @@ Settings::Settings(const QString &settingsDirectory)
settingsInstance->setBackupEnabled(true);
settingsInstance->setBackupSlots(9);
settingsInstance->saveMethod =
pajlada::Settings::SettingManager::SaveMethod::SaveOnExit;
pajlada::Settings::SettingManager::SaveMethod::SaveManually;
initializeSignalVector(this->signalHolder, this->highlightedMessagesSetting,
this->highlightedMessages);
@@ -193,6 +195,16 @@ Settings::~Settings()
Settings::instance_ = this->prevInstance_;
}
void Settings::requestSave() const
{
if (this->disableSaving)
{
return;
}
pajlada::Settings::SettingManager::gSave();
}
void Settings::saveSnapshot()
{
BenchmarkGuard benchmark("Settings::saveSnapshot");
+10 -1
View File
@@ -25,6 +25,8 @@ using TimeoutButton = std::pair<QString, int>;
namespace chatterino {
class Args;
#ifdef Q_OS_WIN32
# define DEFAULT_FONT_FAMILY "Segoe UI"
# define DEFAULT_FONT_SIZE 10
@@ -80,12 +82,19 @@ class Settings
static Settings *instance_;
Settings *prevInstance_ = nullptr;
const bool disableSaving;
public:
Settings(const QString &settingsDirectory);
Settings(const Args &args, const QString &settingsDirectory);
~Settings();
static Settings &instance();
/// Request the settings to be saved to file
///
/// Depending on the launch options, a save might end up not happening
void requestSave() const;
void saveSnapshot();
void restoreSnapshot();