1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-01-01 10:13:30 +00:00

Fixed module null references on shutdown

This commit is contained in:
SpoinkyNL 2016-11-09 13:15:46 +01:00
parent 2d9a656dde
commit 4c766f29b4
6 changed files with 45 additions and 41 deletions

View File

@ -51,34 +51,39 @@ namespace Artemis.Managers
ProfilePreviewModel == null) ProfilePreviewModel == null)
return; return;
var activePreview = GameViewModels.FirstOrDefault(vm => vm.IsActive); lock (GameViewModels)
if (activePreview == null)
{ {
// Should not be active if no selected profile is set var activePreview = GameViewModels.FirstOrDefault(vm => vm.IsActive);
if (_effectManager.ActiveEffect != ProfilePreviewModel)
return;
_logger.Debug("Loading last effect after profile preview"); if (activePreview == null)
var lastEffect = _effectManager.GetLastEffect();
if (lastEffect != null)
_effectManager.ChangeEffect(lastEffect);
else
_effectManager.ClearEffect();
}
else
{
if (_effectManager.ActiveEffect != ProfilePreviewModel && !(_effectManager.ActiveEffect is GameModel))
{ {
_logger.Debug("Activate profile preview"); // Should not be active if no selected profile is set
_effectManager.ChangeEffect(ProfilePreviewModel); if (_effectManager.ActiveEffect != ProfilePreviewModel)
return;
_logger.Debug("Loading last effect after profile preview");
var lastEffect = _effectManager.GetLastEffect();
if (lastEffect != null)
_effectManager.ChangeEffect(lastEffect);
else
_effectManager.ClearEffect();
} }
else
{
if (_effectManager.ActiveEffect != ProfilePreviewModel &&
!(_effectManager.ActiveEffect is GameModel))
{
_logger.Debug("Activate profile preview");
_effectManager.ChangeEffect(ProfilePreviewModel);
}
// LoopManager might be running, this method won't do any harm in that case. // LoopManager might be running, this method won't do any harm in that case.
_loopManager.StartAsync(); _loopManager.StartAsync();
ProfilePreviewModel.ProfileViewModel = activePreview.ProfileEditor.ProfileViewModel; ProfilePreviewModel.ProfileViewModel = activePreview.ProfileEditor.ProfileViewModel;
if (!ReferenceEquals(ProfilePreviewModel.Profile, activePreview.ProfileEditor.SelectedProfile)) if (!ReferenceEquals(ProfilePreviewModel.Profile, activePreview.ProfileEditor.SelectedProfile))
ProfilePreviewModel.Profile = activePreview.ProfileEditor.SelectedProfile; ProfilePreviewModel.Profile = activePreview.ProfileEditor.SelectedProfile;
}
} }
} }
} }

View File

@ -39,7 +39,7 @@ namespace Artemis.Modules.Games.GtaV
// Delay restoring the DLL to allow GTA to release it // Delay restoring the DLL to allow GTA to release it
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
Thread.Sleep(2000); Thread.Sleep(5000);
DllManager.RestoreLogitechDll(); DllManager.RestoreLogitechDll();
}); });
@ -59,17 +59,17 @@ namespace Artemis.Modules.Games.GtaV
private void PipeServerOnPipeMessage(string reply) private void PipeServerOnPipeMessage(string reply)
{ {
if (!Initialized) // if (!Initialized)
return; // return;
//
// Convert the given string to a list of ints // // Convert the given string to a list of ints
var stringParts = reply.Split(' '); // var stringParts = reply.Split(' ');
var parts = new string[stringParts.Length]; // var parts = new string[stringParts.Length];
for (var i = 0; i < stringParts.Length; i++) // for (var i = 0; i < stringParts.Length; i++)
parts[i] = stringParts[i]; // parts[i] = stringParts[i];
//
if (parts[0] == "0") // if (parts[0] == "0")
InterpertrateLighting(parts); // InterpertrateLighting(parts);
} }
private void InterpertrateLighting(string[] parts) private void InterpertrateLighting(string[] parts)

View File

@ -88,9 +88,9 @@ namespace Artemis.Modules.Games.Overwatch
{ {
Initialized = false; Initialized = false;
_stickyStatus.Dispose(); _stickyStatus?.Dispose();
_stickyUltimateReady.Dispose(); _stickyUltimateReady?.Dispose();
_stickyUltimateUsed.Dispose(); _stickyUltimateUsed?.Dispose();
_pipeServer.PipeMessage -= PipeServerOnPipeMessage; _pipeServer.PipeMessage -= PipeServerOnPipeMessage;
base.Dispose(); base.Dispose();

View File

@ -40,8 +40,8 @@ namespace Artemis.Modules.Games.TheDivision
DllManager.RestoreLogitechDll(); DllManager.RestoreLogitechDll();
}); });
_stickyAmmo.Dispose(); _stickyAmmo?.Dispose();
_stickyHp.Dispose(); _stickyHp?.Dispose();
_pipeServer.PipeMessage -= PipeServerOnPipeMessage; _pipeServer.PipeMessage -= PipeServerOnPipeMessage;
base.Dispose(); base.Dispose();

View File

@ -70,7 +70,7 @@ namespace Artemis.Modules.Games.WoW
{ {
Initialized = false; Initialized = false;
_process.Dispose(); _process?.Dispose();
_process = null; _process = null;
base.Dispose(); base.Dispose();
} }

View File

@ -62,7 +62,6 @@ namespace Artemis.Utilities.GameState
private void ListenerRun() private void ListenerRun()
{ {
// TODO: Check for UI issue
while (Running) while (Running)
{ {
_listener.BeginGetContext(HandleRequest, _listener); _listener.BeginGetContext(HandleRequest, _listener);