fix memory leak and set object to null when switching viewer target

This commit is contained in:
Paddy Xu
2017-05-17 21:55:30 +03:00
parent 410411692e
commit 482325a479
11 changed files with 66 additions and 24 deletions

View File

@@ -55,6 +55,7 @@ namespace QuickLook.Plugin.VideoViewer
public void Cleanup()
{
_vp?.Dispose();
_vp = null;
}
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Controls;
using System.Windows.Input;
using FontAwesome.WPF;
@@ -51,11 +52,16 @@ namespace QuickLook.Plugin.VideoViewer
: FontAwesomeIcon.PlayCircleOutline;
}
[DebuggerNonUserCode]
private void ShowErrorNotification(object sender, MediaErrorRoutedEventArgs e)
{
_context.ShowNotification("", "An error occurred while loading the video.");
mediaElement.Stop();
_context.ShowNotification("", "An error occurred while loading the video.");
Dispose();
throw new Exception("fallback to default viewer.");
}
public void LoadAndPlay(string path)