diff --git a/Browser/FormBrowser.cs b/Browser/FormBrowser.cs index 99ab682e..4b37b64c 100644 --- a/Browser/FormBrowser.cs +++ b/Browser/FormBrowser.cs @@ -48,10 +48,13 @@ public bool IsWaiting{ public AnalyticsFile AnalyticsFile => analytics?.File ?? AnalyticsFile.Dummy; + #pragma warning disable IDE0069 // Disposable fields should be disposed private readonly TweetDeckBrowser browser; + private readonly FormNotificationTweet notification; + #pragma warning restore IDE0069 // Disposable fields should be disposed + private readonly PluginManager plugins; private readonly UpdateHandler updates; - private readonly FormNotificationTweet notification; private readonly ContextMenu contextMenu; private readonly UpdateBridge updateBridge; @@ -90,6 +93,7 @@ public FormBrowser(){ Disposed += (sender, args) => { Config.MuteToggled -= Config_MuteToggled; Config.TrayBehaviorChanged -= Config_TrayBehaviorChanged; + browser.Dispose(); }; Config.MuteToggled += Config_MuteToggled; @@ -115,9 +119,7 @@ protected override void Dispose(bool disposing){ if (disposing){ components?.Dispose(); - browser.Dispose(); updates.Dispose(); - notification.Dispose(); contextMenu.Dispose(); notificationScreenshotManager?.Dispose(); diff --git a/Browser/Notification/FormNotificationBase.cs b/Browser/Notification/FormNotificationBase.cs index 5ef75528..6d64b354 100644 --- a/Browser/Notification/FormNotificationBase.cs +++ b/Browser/Notification/FormNotificationBase.cs @@ -103,8 +103,11 @@ protected virtual FormBorderStyle NotificationBorderStyle{ protected double SizeScale => DpiScale * Config.ZoomLevel / 100.0; protected readonly FormBrowser owner; + + #pragma warning disable IDE0069 // Disposable fields should be disposed protected readonly ChromiumWebBrowser browser; - + #pragma warning restore IDE0069 // Disposable fields should be disposed + private readonly ResourceHandlerNotification resourceHandler = new ResourceHandlerNotification(); private DesktopNotification currentNotification; @@ -144,7 +147,11 @@ protected FormNotificationBase(FormBrowser owner, bool enableContextMenu){ this.browser.SetupZoomEvents(); Controls.Add(browser); - Disposed += (sender, args) => this.owner.FormClosed -= owner_FormClosed; + + Disposed += (sender, args) => { + this.owner.FormClosed -= owner_FormClosed; + this.browser.Dispose(); + }; DpiScale = this.GetDPIScale(); @@ -155,7 +162,6 @@ protected FormNotificationBase(FormBrowser owner, bool enableContextMenu){ protected override void Dispose(bool disposing){ if (disposing){ components?.Dispose(); - browser.Dispose(); resourceHandler.Dispose(); } diff --git a/Dialogs/FormGuide.cs b/Dialogs/FormGuide.cs index 6f2b5730..a7dbf367 100644 --- a/Dialogs/FormGuide.cs +++ b/Dialogs/FormGuide.cs @@ -56,7 +56,10 @@ public static void Show(string hash = null){ } } + #pragma warning disable IDE0069 // Disposable fields should be disposed private readonly ChromiumWebBrowser browser; + #pragma warning restore IDE0069 // Disposable fields should be disposed + private string nextUrl; private FormGuide(string url, FormBrowser owner){ @@ -87,12 +90,12 @@ private FormGuide(string url, FormBrowser owner){ browser.SetupZoomEvents(); Controls.Add(browser); + Disposed += (sender, args) => browser.Dispose(); } protected override void Dispose(bool disposing){ if (disposing){ components?.Dispose(); - browser.Dispose(); } base.Dispose(disposing);