Browse Source

Fix unsubscribe not doing anything due to wrong check.

Dariusz Komosinski 6 years ago
parent
commit
3030427c07
1 changed files with 1 additions and 2 deletions
  1. 1 2
      src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs

+ 1 - 2
src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs

@@ -161,9 +161,8 @@ namespace Avalonia.Utilities
                 for (int c = 0; c < _count; ++c)
                 {
                     var reference = _data[c].Subscriber;
-                    TSubscriber instance;
 
-                    if (reference != null && reference.TryGetTarget(out instance) && instance == s)
+                    if (reference != null && reference.TryGetTarget(out TSubscriber instance) && instance == (TSubscriber)s.Target)
                     {
                         _data[c] = default;
                         removed = true;