Skip to content

Commit b125abf

Browse files
authored
Fix: Fixed NullReferenceException in ThemeHelper part 2 (#12185)
1 parent cad12e6 commit b125abf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Files.App/Helpers/ThemeHelper.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static void Initialize()
5050

5151
// Set TitleBar background color
5252
if (currentApplicationWindow is not null)
53-
titleBar = App.GetAppWindow(currentApplicationWindow).TitleBar;
53+
titleBar = App.GetAppWindow(currentApplicationWindow)?.TitleBar;
5454

5555
// Apply the desired theme based on what is set in the application settings
5656
ApplyTheme();
@@ -67,12 +67,13 @@ private static async void UiSettings_ColorValuesChanged(UISettings sender, objec
6767
{
6868
currentApplicationWindow = App.Window;
6969

70-
if (currentApplicationWindow is not null)
71-
titleBar = App.GetAppWindow(currentApplicationWindow).TitleBar;
72-
else
70+
if (currentApplicationWindow is null)
7371
return;
7472
}
7573

74+
if (titleBar is null)
75+
titleBar = App.GetAppWindow(currentApplicationWindow)?.TitleBar;
76+
7677
// Dispatch on UI thread so that we have a current appbar to access and change
7778
await currentApplicationWindow.DispatcherQueue.EnqueueAsync(ApplyTheme);
7879
}

0 commit comments

Comments
 (0)