Skip to content

Commit 5cc4495

Browse files
committed
Fixed possible leak of timers.
1 parent 83aa5e5 commit 5cc4495

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Nodes/BaseHexNode.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public abstract class BaseHexNode : BaseNode
1212
public static DateTime CurrentHighlightTime;
1313
public static readonly TimeSpan HightlightDuration = TimeSpan.FromSeconds(1);
1414

15-
private static readonly Dictionary<IntPtr, ValueTypeWrapper<DateTime>> highlight = new Dictionary<IntPtr, ValueTypeWrapper<DateTime>>();
15+
private static readonly Dictionary<IntPtr, ValueTypeWrapper<DateTime>> HighlightTimer = new Dictionary<IntPtr, ValueTypeWrapper<DateTime>>();
1616

1717
private readonly byte[] buffer;
1818

@@ -52,8 +52,10 @@ protected int Draw(ViewInfo view, int x, int y, string text, int length)
5252
{
5353
var address = view.Address.Add(Offset);
5454

55+
HighlightTimer.RemoveWhere(kv => kv.Value.Value < CurrentHighlightTime);
56+
5557
ValueTypeWrapper<DateTime> until;
56-
if (highlight.TryGetValue(address, out until))
58+
if (HighlightTimer.TryGetValue(address, out until))
5759
{
5860
if (until.Value >= CurrentHighlightTime)
5961
{
@@ -64,14 +66,10 @@ protected int Draw(ViewInfo view, int x, int y, string text, int length)
6466
until.Value = CurrentHighlightTime.Add(HightlightDuration);
6567
}
6668
}
67-
else
68-
{
69-
highlight.Remove(address);
70-
}
7169
}
7270
else if (view.Memory.HasChanged(Offset, MemorySize))
7371
{
74-
highlight.Add(address, CurrentHighlightTime.Add(HightlightDuration));
72+
HighlightTimer.Add(address, CurrentHighlightTime.Add(HightlightDuration));
7573

7674
color = view.Settings.HighlightColor;
7775
}

0 commit comments

Comments
 (0)