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

@@ -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();

View File

@@ -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()