1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 01:58:30 +00:00

Moved reference check for UpdateQueue disposal to the caller to prevent issues with Dispose-overrides

This commit is contained in:
Darth Affe 2023-04-08 14:42:56 +02:00
parent d054d16c10
commit 5b514ff962
2 changed files with 2 additions and 7 deletions

View File

@ -162,7 +162,8 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
try try
{ {
UpdateQueue.RemoveReferencingObject(this); UpdateQueue.RemoveReferencingObject(this);
UpdateQueue.Dispose(); if (!UpdateQueue.HasActiveReferences())
UpdateQueue.Dispose();
} }
catch { /* :( */ } catch { /* :( */ }
try { LedMapping.Clear(); } catch { /* this really shouldn't happen */ } try { LedMapping.Clear(); } catch { /* this really shouldn't happen */ }

View File

@ -112,14 +112,8 @@ public abstract class UpdateQueue<TIdentifier, TData> : AbstractReferenceCountin
} }
/// <inheritdoc /> /// <inheritdoc />
/// <summary>
/// Disposes this queue.
/// Checks if any referencing objects are registered and if so, will return without disposing!
/// </summary>
public virtual void Dispose() public virtual void Dispose()
{ {
if (this.HasActiveReferences()) return;
_updateTrigger.Starting -= OnStartup; _updateTrigger.Starting -= OnStartup;
_updateTrigger.Update -= OnUpdate; _updateTrigger.Update -= OnUpdate;