mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Improve Theme resource handling and suppress async warnings
Add try-catch to UpdateResourceDictionary to prevent crashes from InvalidCastException when updating resources. Set _oldResource to null on error. Suppress VSTHRD103 warnings around SetBlurForWindow to clarify intentional async usage and avoid build warnings.
This commit is contained in:
parent
7b855745d9
commit
a83da2b00f
1 changed files with 16 additions and 7 deletions
|
|
@ -99,12 +99,6 @@ namespace Flow.Launcher.Core.Resource
|
|||
|
||||
private void UpdateResourceDictionary(ResourceDictionary dictionaryToUpdate)
|
||||
{
|
||||
// Add new resources
|
||||
if (!Application.Current.Resources.MergedDictionaries.Contains(dictionaryToUpdate))
|
||||
{
|
||||
Application.Current.Resources.MergedDictionaries.Add(dictionaryToUpdate);
|
||||
}
|
||||
|
||||
// Remove old resources
|
||||
if (_oldResource != null && _oldResource != dictionaryToUpdate &&
|
||||
Application.Current.Resources.MergedDictionaries.Contains(_oldResource))
|
||||
|
|
@ -112,7 +106,20 @@ namespace Flow.Launcher.Core.Resource
|
|||
Application.Current.Resources.MergedDictionaries.Remove(_oldResource);
|
||||
}
|
||||
|
||||
_oldResource = dictionaryToUpdate;
|
||||
// Add new resources
|
||||
try
|
||||
{
|
||||
if (!Application.Current.Resources.MergedDictionaries.Contains(dictionaryToUpdate))
|
||||
{
|
||||
Application.Current.Resources.MergedDictionaries.Add(dictionaryToUpdate);
|
||||
}
|
||||
_oldResource = dictionaryToUpdate;
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
// System.InvalidCastException: Unable to cast object of type 'System.Windows.Media.Color' to type 'System.Windows.Expression'.
|
||||
_oldResource = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -654,7 +661,9 @@ namespace Flow.Launcher.Core.Resource
|
|||
{
|
||||
AutoDropShadow(useDropShadowEffect);
|
||||
}
|
||||
#pragma warning disable VSTHRD103 // Call async methods when in an async method
|
||||
SetBlurForWindow(_settings.Theme, backdropType);
|
||||
#pragma warning restore VSTHRD103 // Call async methods when in an async method
|
||||
|
||||
if (!BlurEnabled)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue