From 925bedc0a67db44b0bd9d5a8827bb5cfb749196e Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Thu, 5 Nov 2020 23:56:51 +0100 Subject: [PATCH] UI - Don't kill/restart on shutdown when a debugger is attached Modules - Attempt to fix #478 --- src/Artemis.Core/Services/ModuleService.cs | 13 ++++++++----- .../Utilities/CurrentProcessUtilities.cs | 8 +++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Artemis.Core/Services/ModuleService.cs b/src/Artemis.Core/Services/ModuleService.cs index aa2aeeb58..1a7a2a428 100644 --- a/src/Artemis.Core/Services/ModuleService.cs +++ b/src/Artemis.Core/Services/ModuleService.cs @@ -101,11 +101,14 @@ namespace Artemis.Core.Services List tasks = new List(); foreach (Module module in modules) { - bool shouldBeActivated = module.EvaluateActivationRequirements(); - if (shouldBeActivated && !module.IsActivated) - tasks.Add(ActivateModule(module)); - else if (!shouldBeActivated && module.IsActivated) - tasks.Add(DeactivateModule(module)); + lock (module) + { + bool shouldBeActivated = module.EvaluateActivationRequirements() && module.Enabled; + if (shouldBeActivated && !module.IsActivated) + tasks.Add(ActivateModule(module)); + else if (!shouldBeActivated && module.IsActivated) + tasks.Add(DeactivateModule(module)); + } } await Task.WhenAll(tasks); diff --git a/src/Artemis.Core/Utilities/CurrentProcessUtilities.cs b/src/Artemis.Core/Utilities/CurrentProcessUtilities.cs index 2df30677b..464aa628f 100644 --- a/src/Artemis.Core/Utilities/CurrentProcessUtilities.cs +++ b/src/Artemis.Core/Utilities/CurrentProcessUtilities.cs @@ -16,8 +16,8 @@ namespace Artemis.Core /// gracefully shut down /// /// - /// The delay in seconds after which to kill the application - /// Whether or not to restart the application after shutdown + /// The delay in seconds after which to kill the application (ignored when a debugger is attached) + /// Whether or not to restart the application after shutdown (ignored when a debugger is attached) public static void Shutdown(int delay, bool restart) { // Always kill the process after the delay has passed, with all the plugins a graceful shutdown cannot be guaranteed @@ -33,7 +33,9 @@ namespace Artemis.Core CreateNoWindow = true, FileName = "PowerShell.exe" }; - Process.Start(info); + + if (!Debugger.IsAttached) + Process.Start(info); // Also attempt a graceful shutdown on the UI thread Execute.OnUIThread(() => Application.Current.Shutdown());