From 70c8da5508a2f2c013e185d208e2d705078084fc Mon Sep 17 00:00:00 2001 From: erri120 Date: Thu, 10 Oct 2019 14:16:14 +0200 Subject: [PATCH] Patch for PR #76 --- Wabbajack/AppState.cs | 37 +++++++++---------------------------- Wabbajack/Compiler.cs | 2 +- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/Wabbajack/AppState.cs b/Wabbajack/AppState.cs index 6029eac8..dbeba156 100644 --- a/Wabbajack/AppState.cs +++ b/Wabbajack/AppState.cs @@ -21,6 +21,7 @@ namespace Wabbajack internal class AppState : ViewModel, IDataErrorInfo { private const int MAX_CACHE_SIZE = 10; + private bool installing = false; private string _mo2Folder; @@ -72,12 +73,12 @@ namespace Wabbajack Dirty = false; dispatcher = d; - var th = new Thread(() => UpdateLoop()) + slideshowThread = new Thread(() => UpdateLoop()) { Priority = ThreadPriority.BelowNormal, IsBackground = true }; - th.Start(); + slideshowThread.Start(); } private void SetupSlideshow() @@ -125,8 +126,8 @@ namespace Wabbajack } } - private int _QueueProgress; - public int QueueProgress { get => _QueueProgress; set => this.RaiseAndSetIfChanged(ref _QueueProgress, value); } + private int _queueProgress; + public int QueueProgress { get => _queueProgress; set => this.RaiseAndSetIfChanged(ref _queueProgress, value); } private List InternalStatus { get; } = new List(); public string LogFile { get; } @@ -380,7 +381,7 @@ namespace Wabbajack Dirty = false; } - if (slidesQueue.Any()) + if (slidesQueue != null && slidesQueue.Any()) { if (DateTime.Now - _lastSlideShowUpdate > TimeSpan.FromSeconds(10)) { @@ -392,7 +393,7 @@ namespace Wabbajack } private void UpdateSlideShowItem(bool fromLoop) { - if (EnableSlideShow) + if (EnableSlideShow && slideshowThread != null && installing) { // max cached files achieved if (_cachedSlides.Count >= MAX_CACHE_SIZE) @@ -551,8 +552,6 @@ namespace Wabbajack if (QueueRandomSlide(true, false)) turns++; - else - continue; } } @@ -648,12 +647,7 @@ namespace Wabbajack UIReady = false; if (Mode == TaskMode.INSTALLING) { - slideshowThread = new Thread(() => UpdateLoop()) - { - Priority = ThreadPriority.BelowNormal, - IsBackground = true - }; - slideshowThread.Start(); + installing = true; var installer = new Installer(_modListPath, _modList, Location) { DownloadFolder = DownloadLocation @@ -676,6 +670,7 @@ namespace Wabbajack { UIReady = true; Running = false; + installing = false; slideshowThread.Abort(); } }) @@ -727,20 +722,6 @@ namespace Wabbajack UIReady = true; } } - - private bool IsFileLocked(string path) - { - bool result = false; - try - { - using (var stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.None)) - { - result = false; - } - } - catch (IOException) { result = true; } - return result; - } } public class CPUStatus diff --git a/Wabbajack/Compiler.cs b/Wabbajack/Compiler.cs index 8d260ee8..31aeb7b0 100644 --- a/Wabbajack/Compiler.cs +++ b/Wabbajack/Compiler.cs @@ -677,7 +677,7 @@ namespace Wabbajack { var cruft_files = new HashSet { - "7z.dll", "7z.exe", "vfs_staged_files\\", "nexus.key_cache", "patch_cache\\", "slideshow_cache\\", + "7z.dll", "7z.exe", "vfs_staged_files\\", "nexus.key_cache", "patch_cache\\", Consts.NexusCacheDirectory + "\\" }; return source =>