Skip to content

Commit ffc6987

Browse files
committed
Revert "WPF - Improve ChromiumWebBrowser Dispose"
This reverts commit 489c0ed.
1 parent 489c0ed commit ffc6987

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

CefSharp.Wpf/ChromiumWebBrowser.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,11 @@ private void InternalDispose(bool disposing)
673673
browser = null;
674674

675675
// Incase we accidentally have a reference to the CEF drag data
676-
currentDragData?.Dispose();
677-
currentDragData = null;
676+
if (currentDragData != null)
677+
{
678+
currentDragData.Dispose();
679+
currentDragData = null;
680+
}
678681

679682
PresentationSource.RemoveSourceChangedHandler(this, PresentationSourceChangedHandler);
680683
// Release window event listeners if PresentationSourceChangedHandler event wasn't
@@ -712,18 +715,17 @@ private void InternalDispose(bool disposing)
712715
CleanupElement.Unloaded -= OnCleanupElementUnloaded;
713716
}
714717

715-
managedCefBrowserAdapter?.Dispose();
716-
managedCefBrowserAdapter = null;
718+
if (managedCefBrowserAdapter != null)
719+
{
720+
managedCefBrowserAdapter.Dispose();
721+
managedCefBrowserAdapter = null;
722+
}
717723

718724
// LifeSpanHandler is set to null after managedCefBrowserAdapter.Dispose so ILifeSpanHandler.DoClose
719725
// is called.
720726
LifeSpanHandler = null;
721727

722-
WpfKeyboardHandler?.Dispose();
723-
WpfKeyboardHandler = null;
724-
725-
RenderHandler?.Dispose();
726-
RenderHandler = null;
728+
WpfKeyboardHandler.Dispose();
727729

728730
source = null;
729731
}

0 commit comments

Comments
 (0)