From 0b12e6a90a83950e5288eccebefc8738c6a8741c Mon Sep 17 00:00:00 2001 From: Caeden Statia Date: Fri, 21 Feb 2020 17:04:16 -0800 Subject: [PATCH] Fix crash when .xaml file doesn't exist with loose themes --- ModAssistant/Classes/Themes.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ModAssistant/Classes/Themes.cs b/ModAssistant/Classes/Themes.cs index ff46bba..4b57135 100644 --- a/ModAssistant/Classes/Themes.cs +++ b/ModAssistant/Classes/Themes.cs @@ -104,11 +104,14 @@ namespace ModAssistant if (loadedThemes.TryGetValue(theme, out Theme newTheme)) { //First, pause our video and hide it. + LoadedTheme = theme; MainWindow.Instance.BackgroundVideo.Pause(); MainWindow.Instance.BackgroundVideo.Visibility = Visibility.Hidden; - Application.Current.Resources.MergedDictionaries.RemoveAt(2); //We might want to change this to a static integer or search by name. - LoadedTheme = theme; - Application.Current.Resources.MergedDictionaries.Insert(2, newTheme.ThemeDictionary); //Insert our new theme into the same spot as last time. + if (newTheme.ThemeDictionary != null) + { + Application.Current.Resources.MergedDictionaries.RemoveAt(2); //We might want to change this to a static integer or search by name. + Application.Current.Resources.MergedDictionaries.Insert(2, newTheme.ThemeDictionary); //Insert our new theme into the same spot as last time. + } Properties.Settings.Default.SelectedTheme = theme; Properties.Settings.Default.Save(); if (sendMessage)