Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NUI] Add remove WebContext callbacks when disposed #6409

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Tizen.NUI/src/internal/WebView/WebContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class WebContext : Disposable
private readonly WebContextPasswordDataListAcquiredProxyCallback passwordDataListAcquiredProxyCallback;
private HttpRequestInterceptedCallback httpRequestInterceptedCallback;
private readonly WebContextHttpRequestInterceptedProxyCallback httpRequestInterceptedProxyCallback;
private DownloadStartedCallback downloadStartedCallback;
private MimeOverriddenCallback mimeOverriddenCallback;

internal WebContext(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
{
Expand Down Expand Up @@ -518,10 +520,11 @@ public void GetFormPasswordList(PasswordDataListAcquiredCallback callback)
[EditorBrowsable(EditorBrowsableState.Never)]
public void RegisterDownloadStartedCallback(DownloadStartedCallback callback)
{
downloadStartedCallback = callback;
IntPtr ip = IntPtr.Zero;
if (callback != null)
if (downloadStartedCallback != null)
{
ip = Marshal.GetFunctionPointerForDelegate(callback);
ip = Marshal.GetFunctionPointerForDelegate(downloadStartedCallback);
}
Interop.WebContext.RegisterDownloadStartedCallback(SwigCPtr, new HandleRef(this, ip));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
Expand All @@ -534,10 +537,11 @@ public void RegisterDownloadStartedCallback(DownloadStartedCallback callback)
[EditorBrowsable(EditorBrowsableState.Never)]
public void RegisterMimeOverriddenCallback(MimeOverriddenCallback callback)
{
mimeOverriddenCallback = callback;
IntPtr ip = IntPtr.Zero;
if (callback != null)
if (mimeOverriddenCallback != null)
{
ip = Marshal.GetFunctionPointerForDelegate(callback);
ip = Marshal.GetFunctionPointerForDelegate(mimeOverriddenCallback);
}
Interop.WebContext.RegisterMimeOverriddenCallback(SwigCPtr, new HandleRef(this, ip));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
Expand Down
4 changes: 4 additions & 0 deletions src/Tizen.NUI/src/public/WebView/WebView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ protected override void Dispose(DisposeTypes type)
return;
}

Context.RegisterDownloadStartedCallback(null);
Context.RegisterMimeOverriddenCallback(null);
Context.RegisterHttpRequestInterceptedCallback(null);

if (type == DisposeTypes.Explicit)
{
//Called by User
Expand Down
Loading