From 25203c53278b04c86dc8aaafa37d0e174d5a18bd Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 16 Dec 2014 21:24:55 +1000 Subject: [PATCH] Create BrowserSettings in ChromiumWebBrowser constructor and explicitly call Dispose (it references an unmanaged resource) --- CefSharp.Wpf/ChromiumWebBrowser.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index 245b607c70..24dc9db8e7 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -338,6 +338,9 @@ public void Dispose() protected virtual void Dispose(bool isdisposing) { + BrowserSettings.Dispose(); + + BrowserSettings = null; ResourceHandler = null; Loaded -= OnLoaded; @@ -470,6 +473,7 @@ public ChromiumWebBrowser() disposables.Add(new DisposableEventWrapper(this, ActualWidthProperty, OnActualSizeChanged)); ResourceHandler = new DefaultResourceHandler(); + BrowserSettings = new BrowserSettings(); } ~ChromiumWebBrowser() @@ -484,7 +488,7 @@ private void CreateOffscreenBrowserWhenActualSizeChanged() return; } - managedCefBrowserAdapter.CreateOffscreenBrowser(BrowserSettings ?? new BrowserSettings(), Address); + managedCefBrowserAdapter.CreateOffscreenBrowser(BrowserSettings, Address); browserCreated = true; }