From 6e5e7cb891724ea21543f8e28b4b848d7db677ec Mon Sep 17 00:00:00 2001 From: Paddy Xu Date: Sun, 15 Oct 2017 16:10:29 +0300 Subject: [PATCH] Fix #92: Make sure the handle is closed --- .../AnimatedImage/GIFAnimationProvider.cs | 4 +--- .../QuickLook.Plugin.TextViewer/TextViewerPanel.xaml.cs | 5 ++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/GIFAnimationProvider.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/GIFAnimationProvider.cs index 816e2fd..eceb5aa 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/GIFAnimationProvider.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/GIFAnimationProvider.cs @@ -20,8 +20,6 @@ using System.Windows; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; -using QuickLook.ExtensionMethods; -using QuickLook.Helpers; namespace QuickLook.Plugin.ImageViewer.AnimatedImage { @@ -31,7 +29,7 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage { var decoder = new GifBitmapDecoder(new Uri(path), BitmapCreateOptions.PreservePixelFormat, - BitmapCacheOption.Default); + BitmapCacheOption.OnLoad); var clock = TimeSpan.Zero; BitmapSource prevFrame = null; diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.xaml.cs index c77452d..e4135a6 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.xaml.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/TextViewerPanel.xaml.cs @@ -85,9 +85,12 @@ namespace QuickLook.Plugin.TextViewer s.Read(buffer, 0, bufferLength); viewer.Encoding = CharsetDetector.DetectFromBytes(buffer).Detected?.Encoding ?? Encoding.Default; + + s.Position = 0; + viewer.Load(s); } - viewer.Load(path); + //viewer.Load(path); viewer.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(path)); } }