Skip to content

Commit

Permalink
CleanupElement - Don't default to Window yet
Browse files Browse the repository at this point in the history
Needs testing, have commented out for now.

Follow up to #14
  • Loading branch information
amaitland committed Sep 19, 2021
1 parent bcd74c7 commit f22cb58
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions CefSharp.Wpf.HwndHost/ChromiumWebBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,11 @@ private void PresentationSourceChangedHandler(object sender, SourceChangedEventA
sourceWindow = window;

// If CleanupElement is null, set the CleanupElement to the new window that the browser is moved in.
if (CleanupElement == null)
{
CleanupElement = window;
}
//TODO: Test and uncomment this
//if (CleanupElement == null)
//{
// CleanupElement = window;
//}
}
}
else if (args.OldSource != null)
Expand All @@ -684,10 +685,11 @@ private void PresentationSourceChangedHandler(object sender, SourceChangedEventA
sourceWindow = null;

// If CleanupElement is the old Window that the browser is moved out of, set CleanupElement to null.
if (CleanupElement == window)
{
CleanupElement = null;
}
//TODO: Test and uncomment this
//if (CleanupElement == window)
//{
// CleanupElement = null;
//}
}
}
}
Expand Down Expand Up @@ -1351,11 +1353,9 @@ public double ZoomLevelIncrement
DependencyProperty.Register(nameof(ZoomLevelIncrement), typeof(double), typeof(ChromiumWebBrowser), new PropertyMetadata(0.10));

/// <summary>
/// The CleanupElement Controls when the BrowserResources will be cleaned up.
/// The ChromiumWebBrowser will register on Unloaded of the provided Element and dispose all resources when that handler is called.
/// By default the cleanup element is the Window that contains the ChromiumWebBrowser.
/// if you want cleanup to happen earlier provide another FrameworkElement.
/// Be aware that this Control is not usable anymore after cleanup is done.
/// The CleanupElement controls when the Browser will be Disposed.
/// The <see cref="ChromiumWebBrowser"/> will be Disposed when <see cref="FrameworkElement.Unloaded"/> is called.
/// Be aware that this Control is not usable anymore after it has been disposed.
/// </summary>
/// <value>The cleanup element.</value>
public FrameworkElement CleanupElement
Expand Down

0 comments on commit f22cb58

Please sign in to comment.