Skip to content

Commit 84ed1fa

Browse files
committed
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.
1 parent a83da2b commit 84ed1fa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,8 @@ private void SetResizeBoarderThickness(Thickness? effectMargin)
644644
/// </summary>
645645
public async Task RefreshFrameAsync()
646646
{
647-
if (Application.Current?.Dispatcher.CheckAccess() != true)
647+
if (Application.Current == null) return;
648+
if (!Application.Current.Dispatcher.CheckAccess())
648649
{
649650
await Application.Current?.Dispatcher.InvokeAsync(RefreshFrameAsync);
650651
return;
@@ -676,9 +677,10 @@ public async Task RefreshFrameAsync()
676677
/// </summary>
677678
public async Task SetBlurForWindowAsync()
678679
{
679-
if (Application.Current?.Dispatcher.CheckAccess() != true)
680+
if (Application.Current == null) return;
681+
if (!Application.Current.Dispatcher.CheckAccess())
680682
{
681-
await Application.Current?.Dispatcher.InvokeAsync(RefreshFrameAsync);
683+
await Application.Current?.Dispatcher.InvokeAsync(SetBlurForWindowAsync);
682684
return;
683685
}
684686

0 commit comments

Comments
 (0)