Skip to content
Permalink
Browse files

[Editor] Preview View Model was not properly removing event handlers (f…

…ixes #438)
  • Loading branch information
xen2 committed Apr 19, 2019
1 parent 52da39c commit be47e4ca32d1c4c444f9c05665fed355c50e21cf
Showing with 5 additions and 0 deletions.
  1. +5 −0 sources/editor/Xenko.GameStudio/PreviewViewModel.cs
@@ -65,10 +65,14 @@ private void Cleanup()
previewService.PreviewAssetUpdated -= PreviewAssetUpdated;
previewService.Dispose();
}

session.ActiveAssetView.SelectedAssets.CollectionChanged -= SelectedAssetsCollectionChanged;
session.ActiveAssetsChanged -= ActiveAssetsChanged;
}

private void ActiveAssetsChanged(object sender, ActiveAssetsChangedArgs e)
{
EnsureNotDestroyed(nameof(PreviewViewModel));
PreviewService?.SetAssetToPreview(e.Assets.Count == 1 ? e.Assets.First() : null);
}

@@ -79,6 +83,7 @@ private void PreviewAssetUpdated(object sender, EventArgs e)

private void SelectedAssetsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
EnsureNotDestroyed(nameof(PreviewViewModel));
if (PreviewService == null)
return;

0 comments on commit be47e4c

Please sign in to comment.
You can’t perform that action at this time.