diff --git a/installer/Installer/Model.cs b/installer/Installer/Model.cs index 18128c4..9ffd19f 100644 --- a/installer/Installer/Model.cs +++ b/installer/Installer/Model.cs @@ -835,7 +835,7 @@ namespace Downloader private static void Download() { Tencent_cos_download Downloader = new Tencent_cos_download(); - int newFile = 0, updateFile = 0; + int newFile = 0; int totalnew = newFileName.Count, totalupdate = updateFileName.Count; filenum = totalnew + totalupdate; updateFailed.Clear(); @@ -1573,24 +1573,25 @@ namespace Downloader ServerDebugAndPythonVisit, } + // !!! 目前此类的各个静态成员从未被赋值过 public class RunInfo //UI需要在调用Launch函数前保证其中数据已经更新并有效 { - static public RunMode mode; - static public string? IP; - static public int port; - static public int studentCount; - static public int trickerCount; - static public int gameTimeSec; - static public string? playbackFileName; - static public int characterID; - static public int type; - static public bool saveDebugLog; - static public bool showDebugLog; - static public bool warningOnly; - static public bool visiting; - static public int occupation; - static public List? playerId = new List(); //两者长度必须与studentCount + trickerCount一致 - static public List? filePath = new List(); + public static RunMode mode = default; + public static string? IP = null; + public static int port = 0; + public static int studentCount = 0; + public static int trickerCount = 0; + public static int gameTimeSec = 0; + public static string? playbackFileName = null; + public static int characterID = 0; + public static int type = 0; + public static bool saveDebugLog = false; + public static bool showDebugLog = false; + public static bool warningOnly = false; + public static bool visiting = false; + public static int occupation = 0; + public static List? playerId = new List(); //两者长度必须与studentCount + trickerCount一致 + public static List? filePath = new List(); } /// diff --git a/installer/Installer/ViewModel.cs b/installer/Installer/ViewModel.cs index 0baa631..4cb2ac1 100644 --- a/installer/Installer/ViewModel.cs +++ b/installer/Installer/ViewModel.cs @@ -20,8 +20,8 @@ namespace starter.viewmodel.settings public class SettingsViewModel : NotificationObject { //定义BackgroundWorker - BackgroundWorker asyncDownloader; - BackgroundWorker asyncUpdater; + BackgroundWorker? asyncDownloader; + BackgroundWorker? asyncUpdater; BackgroundWorker asyncInitializer; /// /// Model object @@ -202,6 +202,11 @@ namespace starter.viewmodel.settings private void AsyncUpdater_DoWork(object? sender, DoWorkEventArgs e) { + if (asyncUpdater is null) + { + throw new InvalidOperationException("asyncUpdater is null"); + } + if (asyncUpdater.CancellationPending) { e.Cancel = true; @@ -230,6 +235,11 @@ namespace starter.viewmodel.settings private void AsyncDownloader_DoWork(object? sender, DoWorkEventArgs e) { + if (asyncDownloader is null) + { + throw new InvalidOperationException("asyncDownloader is null"); + } + if (asyncDownloader.CancellationPending) { e.Cancel = true; @@ -710,7 +720,7 @@ namespace starter.viewmodel.settings { Status = SettingsModel.Status.successful; }*/ - if (asyncDownloader.IsBusy) + if (asyncDownloader?.IsBusy ?? true) return; else { @@ -776,7 +786,7 @@ namespace starter.viewmodel.settings } else Status = SettingsModel.Status.error;*/ - if (asyncUpdater.IsBusy) + if (asyncUpdater?.IsBusy ?? true) return; else asyncUpdater.RunWorkerAsync("Manual"); @@ -905,7 +915,7 @@ namespace starter.viewmodel.settings { Status = SettingsModel.Status.working; this.RaisePropertyChanged("ProgressVis"); - if (asyncUpdater.IsBusy) + if (asyncUpdater?.IsBusy ?? true) return; else asyncUpdater.RunWorkerAsync("Auto");