diff --git a/QuickLook/Helpers/ProcessHelper.cs b/QuickLook/Helpers/ProcessHelper.cs
new file mode 100644
index 0000000..471e283
--- /dev/null
+++ b/QuickLook/Helpers/ProcessHelper.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Threading.Tasks;
+
+namespace QuickLook.Helpers
+{
+ internal class ProcessHelper
+ {
+ // ReSharper disable once InconsistentNaming
+ public static void PerformAggressiveGC()
+ {
+ // delay some time to make sure that all windows are closed
+ Task.Delay(1000).ContinueWith(t => GC.Collect(GC.MaxGeneration));
+ }
+ }
+}
\ No newline at end of file
diff --git a/QuickLook/MainWindowTransparent.xaml.cs b/QuickLook/MainWindowTransparent.xaml.cs
index 8dafced..b5ebf01 100644
--- a/QuickLook/MainWindowTransparent.xaml.cs
+++ b/QuickLook/MainWindowTransparent.xaml.cs
@@ -4,10 +4,12 @@ using System.IO;
using System.Runtime.ExceptionServices;
using System.Windows;
using System.Windows.Forms;
+using System.Windows.Input;
using System.Windows.Threading;
using QuickLook.Helpers;
using QuickLook.Helpers.BlurLibrary;
using QuickLook.Plugin;
+using KeyEventArgs = System.Windows.Forms.KeyEventArgs;
namespace QuickLook
{
@@ -81,15 +83,12 @@ namespace QuickLook
internal void UnloadPlugin()
{
- // clear ref to control
- //container.Content = null;
-
ContextObject.Reset();
_plugin?.Cleanup();
_plugin = null;
- GC.Collect();
+ ProcessHelper.PerformAggressiveGC();
}
internal void BeginShow(IViewer matchedPlugin, string path)
@@ -97,6 +96,8 @@ namespace QuickLook
_path = path;
_plugin = matchedPlugin;
+ ContextObject.ViewerWindow = this;
+
// get window size before showing it
_plugin.Prepare(path, ContextObject);
@@ -150,8 +151,14 @@ namespace QuickLook
internal void BeginHide()
{
+ // the focused element will not processed by GC: https://stackoverflow.com/questions/30848939/memory-leak-due-to-window-efectivevalues-retention
+ FocusManager.SetFocusedElement(this, null);
+ Keyboard.ClearFocus();
+
UnloadPlugin();
Hide();
+
+ ProcessHelper.PerformAggressiveGC();
}
}
}
\ No newline at end of file
diff --git a/QuickLook/Properties/Settings.Designer.cs b/QuickLook/Properties/Settings.Designer.cs
index 9c53c26..d19554c 100644
--- a/QuickLook/Properties/Settings.Designer.cs
+++ b/QuickLook/Properties/Settings.Designer.cs
@@ -8,21 +8,17 @@
//
//------------------------------------------------------------------------------
-namespace QuickLook.Properties
-{
-
-
+namespace QuickLook.Properties {
+
+
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
- {
-
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default
- {
- get
- {
+
+ public static Settings Default {
+ get {
return defaultInstance;
}
}
diff --git a/QuickLook/QuickLook.csproj b/QuickLook/QuickLook.csproj
index d1298b9..a17f49e 100644
--- a/QuickLook/QuickLook.csproj
+++ b/QuickLook/QuickLook.csproj
@@ -8,7 +8,7 @@
WinExe
QuickLook
QuickLook
- v4.5.2
+ v4.6.2
512
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
4
@@ -28,6 +28,7 @@
1.0.0.%2a
false
true
+
Resources\app.ico
@@ -108,6 +109,7 @@
+