From 444978b97acc2444ffc734dce587742be067c69e Mon Sep 17 00:00:00 2001 From: halinhtvn3a <77691576+halinhtvn3a@users.noreply.github.com> Date: Fri, 27 Mar 2026 00:50:43 +0700 Subject: [PATCH] fix(ui): missing null check before accessing mainwindow.unityinstallationssource The code accesses `MainWindow.unityInstallationsSource` without checking if it's null. This can cause a NullReferenceException when the window is opened before the main window has initialized the data source, leading to a crash. Affected files: UpgradeWindow.xaml.cs Signed-off-by: halinhtvn3a <77691576+halinhtvn3a@users.noreply.github.com> --- UnityLauncherPro/UpgradeWindow.xaml.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/UnityLauncherPro/UpgradeWindow.xaml.cs b/UnityLauncherPro/UpgradeWindow.xaml.cs index 5e5944e..12d5b32 100644 --- a/UnityLauncherPro/UpgradeWindow.xaml.cs +++ b/UnityLauncherPro/UpgradeWindow.xaml.cs @@ -21,7 +21,14 @@ public UpgradeWindow(string currentVersion, string projectPath, string commandLi if (gridAvailableVersions.ItemsSource == null) { - gridAvailableVersions.ItemsSource = MainWindow.unityInstallationsSource; + if (MainWindow.unityInstallationsSource != null) + { + gridAvailableVersions.ItemsSource = MainWindow.unityInstallationsSource; + } + else + { + gridAvailableVersions.ItemsSource = new System.Collections.Generic.List(); + } } gridAvailableVersions.SelectedItem = null;