Skip to content

Commit

Permalink
BrowserItemViewModel dispose
Browse files Browse the repository at this point in the history
- implement dispose method inside the BrowserItemViewModel  to unsubscribe from the ItemsOnCollectionChanged event
  • Loading branch information
dnenov committed Nov 22, 2023
1 parent b822e2c commit 8096f65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,7 @@ internal void ClearSearchResults()
{
ele.RequestDownload -= PackageOnExecuted;
ele.RequestShowFileDialog -= OnRequestShowFileDialog;
ele?.Dispose();
}
this.SearchResults.Clear();
}
Expand Down
9 changes: 7 additions & 2 deletions src/DynamoCoreWpf/ViewModels/Search/BrowserItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
using Dynamo.Search.SearchElements;
using Dynamo.ViewModels;
using Dynamo.Wpf.Extensions;
using NotificationObject = Dynamo.Core.NotificationObject;
using Prism.Commands;
using NotificationObject = Dynamo.Core.NotificationObject;

namespace Dynamo.Wpf.ViewModels
{
public abstract class BrowserItemViewModel : NotificationObject
public abstract class BrowserItemViewModel : NotificationObject, IDisposable
{
public ICommand ToggleIsExpandedCommand { get; protected set; }
public BrowserItem Model { get; private set; }
Expand Down Expand Up @@ -75,6 +75,11 @@ internal static BrowserInternalElementViewModel WrapExplicit(BrowserInternalElem
return new BrowserInternalElementViewModel(elem);
}

public void Dispose()
{
Model.Items.CollectionChanged -= ItemsOnCollectionChanged;
}

#endregion

}
Expand Down

0 comments on commit 8096f65

Please sign in to comment.