From c3e7d562489389e8890aa171e07f092ad57349ba Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 18 May 2022 13:59:19 +0200 Subject: [PATCH] ensure that lighting systems are properly disposed --- Illumilib/System/CorsairLighting.cs | 4 ---- Illumilib/System/LightingSystem.cs | 10 ++++++++-- Illumilib/System/LogitechLighting.cs | 1 + Illumilib/System/RazerLighting.cs | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Illumilib/System/CorsairLighting.cs b/Illumilib/System/CorsairLighting.cs index c0d4493..d902e3a 100644 --- a/Illumilib/System/CorsairLighting.cs +++ b/Illumilib/System/CorsairLighting.cs @@ -26,10 +26,6 @@ namespace Illumilib.System { } } - public override void Dispose() { - // no op - } - public override void SetAllLighting(float r, float g, float b) { foreach (var device in this.devices) { device.SetAllColors(r, g, b); diff --git a/Illumilib/System/LightingSystem.cs b/Illumilib/System/LightingSystem.cs index e372211..0adf140 100644 --- a/Illumilib/System/LightingSystem.cs +++ b/Illumilib/System/LightingSystem.cs @@ -5,9 +5,11 @@ namespace Illumilib.System { public abstract LightingType Type { get; } - public abstract bool Initialize(); + ~LightingSystem() { + this.Dispose(); + } - public abstract void Dispose(); + public abstract bool Initialize(); public abstract void SetAllLighting(float r, float g, float b); @@ -21,5 +23,9 @@ namespace Illumilib.System { public abstract void SetMouseLighting(float r, float g, float b); + public virtual void Dispose() { + GC.SuppressFinalize(this); + } + } } \ No newline at end of file diff --git a/Illumilib/System/LogitechLighting.cs b/Illumilib/System/LogitechLighting.cs index 64d739e..80a29d5 100644 --- a/Illumilib/System/LogitechLighting.cs +++ b/Illumilib/System/LogitechLighting.cs @@ -18,6 +18,7 @@ namespace Illumilib.System { } public override void Dispose() { + base.Dispose(); this.ClearBitmap(); LogitechGsdk.LogiLedShutdown(); } diff --git a/Illumilib/System/RazerLighting.cs b/Illumilib/System/RazerLighting.cs index a567bf8..d842d9e 100644 --- a/Illumilib/System/RazerLighting.cs +++ b/Illumilib/System/RazerLighting.cs @@ -21,6 +21,7 @@ namespace Illumilib.System { } public override void Dispose() { + base.Dispose(); this.chroma.UninitializeAsync(); this.effectOutdated = true; }