Browse Source

Merge branch 'new-weak-events' into fixes/affect-renderer-memory-leak

pull/2331/head
Nikita Tsukanov 8 years ago
parent
commit
7dfb289254
  1. 5
      src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs

5
src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs

@ -132,6 +132,7 @@ namespace Avalonia.Utilities
public void Add(EventHandler<T> s) public void Add(EventHandler<T> s)
{ {
Compact(true);
if (_count == _data.Length) if (_count == _data.Length)
{ {
//Extend capacity //Extend capacity
@ -174,7 +175,7 @@ namespace Avalonia.Utilities
} }
} }
void Compact() void Compact(bool preventDestroy = false)
{ {
int empty = -1; int empty = -1;
for (int c = 0; c < _count; c++) for (int c = 0; c < _count; c++)
@ -193,7 +194,7 @@ namespace Avalonia.Utilities
} }
if (empty != -1) if (empty != -1)
_count = empty; _count = empty;
if (_count == 0) if (_count == 0 && !preventDestroy)
Destroy(); Destroy();
} }

Loading…
Cancel
Save