From 798556c06883ce6d0b64c982219835ef15f7e79d Mon Sep 17 00:00:00 2001 From: VodBox Date: Sun, 15 Dec 2019 11:24:34 +1300 Subject: [PATCH] UI: Ensure OBS launches when theme is missing This change makes it so OBS will still launch even if a theme is missing. This change also deprecates the "CurrentTheme" config key, and is replaced by "CurrentTheme2". This is because a previous change to make sure OBS fell back to the System theme in case of a missing theme had been accidentally removed. Changing the key prevents a new version of OBS setting a theme that doesn't exist in an older version, which would prevent that version from launching. --- UI/obs-app.cpp | 22 ++++++++++++++-------- UI/window-basic-settings.cpp | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp index c2cb95e12..6da08dd1c 100644 --- a/UI/obs-app.cpp +++ b/UI/obs-app.cpp @@ -1071,21 +1071,27 @@ bool OBSApp::InitTheme() defaultPalette = palette(); const char *themeName = - config_get_string(globalConfig, "General", "CurrentTheme"); + config_get_string(globalConfig, "General", "CurrentTheme2"); - if (!themeName) { + if (!themeName) + /* Use deprecated "CurrentTheme" value if available */ + themeName = config_get_string(globalConfig, "General", + "CurrentTheme"); + if (!themeName) /* Use deprecated "Theme" value if available */ themeName = config_get_string(globalConfig, "General", "Theme"); - if (!themeName) - themeName = DEFAULT_THEME; - if (!themeName) - themeName = "Dark"; - } + if (!themeName) + themeName = DEFAULT_THEME; + if (!themeName) + themeName = "Dark"; if (strcmp(themeName, "Default") == 0) themeName = "System"; - return SetTheme(themeName); + if (strcmp(themeName, "System") != 0 && SetTheme(themeName)) + return true; + + return SetTheme("System"); } OBSApp::OBSApp(int &argc, char **argv, profiler_name_store_t *store) diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 04d25a6b1..3809becb7 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -2760,7 +2760,7 @@ void OBSBasicSettings::SaveGeneralSettings() themeData = DEFAULT_THEME; if (WidgetChanged(ui->theme)) { - config_set_string(GetGlobalConfig(), "General", "CurrentTheme", + config_set_string(GetGlobalConfig(), "General", "CurrentTheme2", QT_TO_UTF8(themeData)); App()->SetTheme(themeData.toUtf8().constData());