From 84ed1fa1e1cc23aa4c776762a52cef0ced21451f Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 28 Feb 2026 23:22:06 +0800 Subject: [PATCH] Add null checks and fix dispatcher invocation in Theme Added early returns if Application.Current is null in RefreshFrameAsync and SetBlurForWindowAsync to prevent null reference exceptions. Updated dispatcher access checks and ensured the correct method is invoked asynchronously for each case, improving robustness and reliability. --- Flow.Launcher.Core/Resource/Theme.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 76a74b711..be849228a 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -644,7 +644,8 @@ namespace Flow.Launcher.Core.Resource /// public async Task RefreshFrameAsync() { - if (Application.Current?.Dispatcher.CheckAccess() != true) + if (Application.Current == null) return; + if (!Application.Current.Dispatcher.CheckAccess()) { await Application.Current?.Dispatcher.InvokeAsync(RefreshFrameAsync); return; @@ -676,9 +677,10 @@ namespace Flow.Launcher.Core.Resource /// public async Task SetBlurForWindowAsync() { - if (Application.Current?.Dispatcher.CheckAccess() != true) + if (Application.Current == null) return; + if (!Application.Current.Dispatcher.CheckAccess()) { - await Application.Current?.Dispatcher.InvokeAsync(RefreshFrameAsync); + await Application.Current?.Dispatcher.InvokeAsync(SetBlurForWindowAsync); return; }