diff --git a/src/duckstation-qt/main.cpp b/src/duckstation-qt/main.cpp index 92a8f03da..66bf4bf51 100644 --- a/src/duckstation-qt/main.cpp +++ b/src/duckstation-qt/main.cpp @@ -55,8 +55,6 @@ int main(int argc, char* argv[]) window->startupUpdateCheck(); } - window->reportSettingsVersionMismatchString(); - int result = app.exec(); window.reset(); diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 64b5194c0..eb1a97b0f 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -1121,13 +1121,6 @@ void MainWindow::startupUpdateCheck() checkForUpdates(false); } -void MainWindow::reportSettingsVersionMismatchString() -{ - const QString mismatch_str = QString::fromStdString(m_host_interface->GetSettingsVersionMismatchString()); - if (!mismatch_str.isEmpty()) - reportError(mismatch_str); -} - void MainWindow::updateDebugMenuVisibility() { const bool visible = m_host_interface->GetBoolSettingValue("Main", "ShowDebugMenu", false); diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index a384f4cbe..10f187296 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -30,10 +30,6 @@ public: /// Performs update check if enabled in settings. void startupUpdateCheck(); - /// Reports m_host_interface's settings version mismatch string. Does nothing if string is empty (no settings version - /// mismatch detected). - void reportSettingsVersionMismatchString(); - public Q_SLOTS: /// Updates debug menu visibility (hides if disabled). void updateDebugMenuVisibility(); diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index a028337a4..fe6909b5b 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -680,8 +680,14 @@ void QtHostInterface::OnSystemStateSaved(bool global, s32 slot) void QtHostInterface::LoadSettings() { m_settings_interface = std::make_unique(CommonHostInterface::GetSettingsFileName()); + Log::SetConsoleOutputParams(true); + + if (!CommonHostInterface::CheckSettings(*m_settings_interface.get())) + { + QTimer::singleShot(1000, + [this]() { ReportError("Settings version mismatch, settings have been reset to defaults."); }); + } - CommonHostInterface::CheckSettings(*m_settings_interface.get()); CommonHostInterface::LoadSettings(*m_settings_interface.get()); CommonHostInterface::FixIncompatibleSettings(false); } diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index e8d444229..6916c99e6 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -47,10 +47,12 @@ public: bool Initialize() override; void Shutdown() override; +public Q_SLOTS: void ReportError(const char* message) override; void ReportMessage(const char* message) override; bool ConfirmMessage(const char* message) override; +public: /// Thread-safe settings access. std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "") override; bool GetBoolSettingValue(const char* section, const char* key, bool default_value = false) override; diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index 499525347..8013cae1e 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -1989,19 +1989,19 @@ std::string CommonHostInterface::GetMostRecentResumeSaveStatePath() const return std::move(most_recent->FileName); } -void CommonHostInterface::CheckSettings(SettingsInterface& si) +bool CommonHostInterface::CheckSettings(SettingsInterface& si) { const int settings_version = si.GetIntValue("Main", "SettingsVersion", -1); if (settings_version == SETTINGS_VERSION) - return; + return true; - m_settings_version_mismatch_str = StringUtil::StdStringFromFormat( - "Settings version %d does not match expected version %d, resetting", settings_version, SETTINGS_VERSION); - ReportError(m_settings_version_mismatch_str.c_str()); + Log_ErrorPrintf("Settings version %d does not match expected version %d, resetting", settings_version, + SETTINGS_VERSION); si.Clear(); si.SetIntValue("Main", "SettingsVersion", SETTINGS_VERSION); SetDefaultSettings(si); + return false; } void CommonHostInterface::SetDefaultSettings(SettingsInterface& si) @@ -2103,11 +2103,6 @@ void CommonHostInterface::CheckForSettingsChanges(const Settings& old_settings) UpdateInputMap(); } -const std::string& CommonHostInterface::GetSettingsVersionMismatchString() const -{ - return m_settings_version_mismatch_str; -} - void CommonHostInterface::SetTimerResolutionIncreased(bool enabled) { if (m_timer_resolution_increased == enabled) diff --git a/src/frontend-common/common_host_interface.h b/src/frontend-common/common_host_interface.h index 07ad70d97..5fb7c61f7 100644 --- a/src/frontend-common/common_host_interface.h +++ b/src/frontend-common/common_host_interface.h @@ -174,10 +174,6 @@ public: /// Reloads post processing shaders with the current configuration. void ReloadPostProcessingShaders(); - /// Returns an empty string if no settings version mismatch was detected, non-empty otherwise. Should not be called - /// before CheckSettings(SettingsInterface& si). - const std::string& GetSettingsVersionMismatchString() const; - protected: enum : u32 { @@ -282,7 +278,7 @@ protected: std::string GetCheatFileName() const; /// Ensures the settings is valid and the correct version. If not, resets to defaults. - void CheckSettings(SettingsInterface& si); + bool CheckSettings(SettingsInterface& si); /// Restores all settings to defaults. virtual void SetDefaultSettings(SettingsInterface& si) override; @@ -375,8 +371,6 @@ private: // running in batch mode? i.e. exit after stopping emulation bool m_batch_mode = false; - std::string m_settings_version_mismatch_str; - #ifdef WITH_DISCORD_PRESENCE // discord rich presence bool m_discord_presence_enabled = false;