fix: Fixed account switch not being saved if no other settings were changed (#5558)
This commit is contained in:
+1
-4
@@ -266,10 +266,7 @@ void runGui(QApplication &a, const Paths &paths, Settings &settings,
|
||||
app.run(a);
|
||||
app.save();
|
||||
|
||||
if (!args.dontSaveSettings)
|
||||
{
|
||||
pajlada::Settings::SettingManager::gSave();
|
||||
}
|
||||
settings.requestSave();
|
||||
|
||||
chatterino::NetworkManager::deinit();
|
||||
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
|
||||
IvrApi::initialize();
|
||||
Helix::initialize();
|
||||
|
||||
Settings settings(paths->settingsDirectory);
|
||||
Settings settings(args, paths->settingsDirectory);
|
||||
|
||||
runGui(a, *paths, settings, args, updates);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchCommon.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -54,6 +55,8 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
||||
{
|
||||
app->getAccounts()->twitch.currentUsername = newUsername;
|
||||
}
|
||||
|
||||
getSettings()->requestSave();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -435,8 +435,10 @@ void SettingsDialog::onOkClicked()
|
||||
if (!getApp()->getArgs().dontSaveSettings)
|
||||
{
|
||||
getApp()->getCommands()->save();
|
||||
pajlada::Settings::SettingManager::gSave();
|
||||
}
|
||||
|
||||
getSettings()->requestSave();
|
||||
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user