mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Core - Corrected disposable pattern usage
Core - Further nullable refactoring..
This commit is contained in:
1 parent
27e25f22ed
commit
b185b28645
38 files changed
+429
-162
No files matched your search
@@ -97,19 +97,32 @@ namespace Artemis.Core.LayerBrushes
|
||||
|
||||
internal abstract void InternalRender(SKCanvas canvas, SKRect path, SKPaint paint);
|
||||
|
||||
internal virtual void Dispose(bool disposing)
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Releases the unmanaged resources used by the object and optionally releases the managed resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing">
|
||||
/// <see langword="true" /> to release both managed and unmanaged resources;
|
||||
/// <see langword="false" /> to release only unmanaged resources.
|
||||
/// </param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
DisableLayerBrush();
|
||||
BaseProperties?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
DisableLayerBrush();
|
||||
BaseProperties?.Dispose();
|
||||
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Artemis.Core.LayerBrushes
|
||||
{
|
||||
// I imagine a null reference here can be confusing, so lets throw an exception explaining what to do
|
||||
if (_properties == null)
|
||||
throw new ArtemisPluginException("Cannot access brush properties until OnPropertiesInitialized has been called");
|
||||
throw new InvalidOperationException("Cannot access brush properties until OnPropertiesInitialized has been called");
|
||||
return _properties;
|
||||
}
|
||||
internal set => _properties = value;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Artemis.Core.LayerBrushes
|
||||
LayerBrushStore.Add(descriptor);
|
||||
}
|
||||
|
||||
private void OnDisabled(object sender, EventArgs e)
|
||||
private void OnDisabled(object? sender, EventArgs e)
|
||||
{
|
||||
// The store will clean up the registrations by itself, the plugin just needs to clear its own list
|
||||
_layerBrushDescriptors.Clear();
|
||||
|
||||
@@ -56,7 +56,10 @@ namespace Artemis.Core.LayerBrushes
|
||||
UpdateLedGroup();
|
||||
}
|
||||
|
||||
internal override void Dispose(bool disposing)
|
||||
#region IDisposable
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
@@ -67,13 +70,15 @@ namespace Artemis.Core.LayerBrushes
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// Not used in this effect type
|
||||
internal override void InternalRender(SKCanvas canvas, SKRect bounds, SKPaint paint)
|
||||
{
|
||||
throw new NotImplementedException("RGB.NET layer effectes do not implement InternalRender");
|
||||
}
|
||||
|
||||
private void LayerOnRenderPropertiesUpdated(object sender, EventArgs e)
|
||||
private void LayerOnRenderPropertiesUpdated(object? sender, EventArgs e)
|
||||
{
|
||||
UpdateLedGroup();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user