mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-15 12:49:13 +00:00
fix memory leak and set object to null when switching viewer target
This commit is contained in:
@@ -127,6 +127,9 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
|
||||
private string[] GetPathFragments(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return new string[0];
|
||||
|
||||
var frags = path.Split('\\', '/').Where(f => !string.IsNullOrEmpty(f)).ToArray();
|
||||
|
||||
return frags.Select((s, i) => frags.Take(i + 1).Aggregate((a, b) => a + "\\" + b)).ToArray();
|
||||
|
@@ -16,18 +16,18 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
if (Directory.Exists(path))
|
||||
return false;
|
||||
|
||||
using (var stream = File.OpenRead(path))
|
||||
switch (Path.GetExtension(path).ToLower())
|
||||
{
|
||||
try
|
||||
{
|
||||
ArchiveFactory.Open(stream);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
case ".zip":
|
||||
case ".rar":
|
||||
case ".7z":
|
||||
case ".gz":
|
||||
case ".tar":
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Prepare(string path, ContextObject context)
|
||||
@@ -50,6 +50,7 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
_panel?.Dispose();
|
||||
_panel = null;
|
||||
}
|
||||
|
||||
~Plugin()
|
||||
|
@@ -48,6 +48,7 @@ namespace QuickLook.Plugin.HtmlViewer
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
_panel?.Dispose();
|
||||
_panel = null;
|
||||
}
|
||||
|
||||
~Plugin()
|
||||
|
@@ -52,6 +52,7 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
|
||||
public void Cleanup()
|
||||
{
|
||||
_ip = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -49,6 +49,7 @@ namespace QuickLook.Plugin.MarkdownViewer
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
_panel?.Dispose();
|
||||
_panel = null;
|
||||
}
|
||||
|
||||
~Plugin()
|
||||
|
@@ -58,6 +58,7 @@ namespace QuickLook.Plugin.TextViewer
|
||||
|
||||
public void Cleanup()
|
||||
{
|
||||
_tvp = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -55,6 +55,7 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
public void Cleanup()
|
||||
{
|
||||
_vp?.Dispose();
|
||||
_vp = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user