From 49d0c9eebedcb117283f846c9a54db550eb376f0 Mon Sep 17 00:00:00 2001 From: Paddy Xu Date: Sat, 15 Sep 2018 16:25:24 +0300 Subject: [PATCH] Fix crash when closing preview quickly --- .../QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs index e20582c..d26b001 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs @@ -44,8 +44,7 @@ namespace QuickLook.Plugin.VideoViewer { private readonly ContextObject _context; private BitmapSource _coverArt; - - private bool _hasEnded; + private bool _hasVideo; private bool _isPlaying; private bool _wasPlaying; @@ -147,6 +146,9 @@ namespace QuickLook.Plugin.VideoViewer private void MediaOpened(object o, RoutedEventArgs args) { + if (mediaElement == null) + return; + HasVideo = mediaElement.HasVideo; _context.IsBusy = false; @@ -164,6 +166,9 @@ namespace QuickLook.Plugin.VideoViewer private void MediaEnded(object sender, RoutedEventArgs e) { + if (mediaElement == null) + return; + IsPlaying = false; mediaElement.MediaPosition = 0;