ensure that lighting systems are properly disposed

This commit is contained in:
Ell 2022-05-18 13:59:19 +02:00
parent 9a5391573b
commit c3e7d56248
4 changed files with 10 additions and 6 deletions

View file

@ -26,10 +26,6 @@ namespace Illumilib.System {
} }
} }
public override void Dispose() {
// no op
}
public override void SetAllLighting(float r, float g, float b) { public override void SetAllLighting(float r, float g, float b) {
foreach (var device in this.devices) { foreach (var device in this.devices) {
device.SetAllColors(r, g, b); device.SetAllColors(r, g, b);

View file

@ -5,9 +5,11 @@ namespace Illumilib.System {
public abstract LightingType Type { get; } 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); 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 abstract void SetMouseLighting(float r, float g, float b);
public virtual void Dispose() {
GC.SuppressFinalize(this);
}
} }
} }

View file

@ -18,6 +18,7 @@ namespace Illumilib.System {
} }
public override void Dispose() { public override void Dispose() {
base.Dispose();
this.ClearBitmap(); this.ClearBitmap();
LogitechGsdk.LogiLedShutdown(); LogitechGsdk.LogiLedShutdown();
} }

View file

@ -21,6 +21,7 @@ namespace Illumilib.System {
} }
public override void Dispose() { public override void Dispose() {
base.Dispose();
this.chroma.UninitializeAsync(); this.chroma.UninitializeAsync();
this.effectOutdated = true; this.effectOutdated = true;
} }