mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 03:32:37 +00:00
Core - IAudioHandler now implements IDisposable
IAudioHandler.Dispose is called when the ChromiumWebBrowser instance is being Disposed. This is a breaking change. Resolves #3598
This commit is contained in:
@@ -275,7 +275,7 @@ namespace CefSharp.OffScreen
|
||||
|
||||
// Release reference to handlers, except LifeSpanHandler which is done after Disposing
|
||||
// ManagedCefBrowserAdapter otherwise the ILifeSpanHandler.DoClose will not be invoked.
|
||||
this.SetHandlersToNullExceptLifeSpan();
|
||||
FreeHandlersExceptLifeSpan();
|
||||
|
||||
browser = null;
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ namespace CefSharp.WinForms
|
||||
|
||||
// Release reference to handlers, except LifeSpanHandler which is done after Disposing
|
||||
// ManagedCefBrowserAdapter otherwise the ILifeSpanHandler.DoClose will not be invoked.
|
||||
this.SetHandlersToNullExceptLifeSpan();
|
||||
FreeHandlersExceptLifeSpan();
|
||||
|
||||
browser = null;
|
||||
|
||||
|
||||
@@ -637,7 +637,7 @@ namespace CefSharp.Wpf
|
||||
|
||||
// Release reference to handlers, except LifeSpanHandler which is done after Disposing
|
||||
// ManagedCefBrowserAdapter otherwise the ILifeSpanHandler.DoClose will not be invoked.
|
||||
this.SetHandlersToNullExceptLifeSpan();
|
||||
this.FreeHandlersExceptLifeSpan();
|
||||
|
||||
browser = null;
|
||||
|
||||
|
||||
@@ -13,6 +13,17 @@ namespace CefSharp.Handler
|
||||
/// </summary>
|
||||
public class AudioHandler : IAudioHandler
|
||||
{
|
||||
private bool isDisposed;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating this <see cref="AudioHandler"/> instance
|
||||
/// has been disposed.
|
||||
/// </summary>
|
||||
public bool IsDisposed
|
||||
{
|
||||
get { return isDisposed; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
bool IAudioHandler.GetAudioParameters(IWebBrowser chromiumWebBrowser, IBrowser browser, ref AudioParameters parameters)
|
||||
{
|
||||
@@ -117,5 +128,21 @@ namespace CefSharp.Handler
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and managed resources
|
||||
/// </summary>
|
||||
/// <param name="disposing"><see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
isDisposed = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace CefSharp
|
||||
/// Implement this interface to handle audio events
|
||||
/// All methods will be called on the CEF UI thread
|
||||
/// </summary>
|
||||
public interface IAudioHandler
|
||||
public interface IAudioHandler : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Called on the CEF UI thread to allow configuration of audio stream parameters.
|
||||
|
||||
@@ -326,8 +326,13 @@ namespace CefSharp.WinForms
|
||||
|
||||
partial void OnAfterBrowserCreated(IBrowser browser);
|
||||
|
||||
private void SetHandlersToNullExceptLifeSpan()
|
||||
/// <summary>
|
||||
/// Sets the handler references to null.
|
||||
/// Where required also calls Dispose().
|
||||
/// </summary>
|
||||
private void FreeHandlersExceptLifeSpan()
|
||||
{
|
||||
AudioHandler?.Dispose();
|
||||
AudioHandler = null;
|
||||
DialogHandler = null;
|
||||
FindHandler = null;
|
||||
|
||||
Reference in New Issue
Block a user