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

fix System.NullReferenceException when disconnecting Handler #87

Merged
merged 1 commit into from
Oct 29, 2024
Merged
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
6 changes: 6 additions & 0 deletions HybridWebView/HybridWebView.cs
Original file line number Diff line number Diff line change
@@ -62,6 +62,12 @@ protected override async void OnHandlerChanged()

await InitializeHybridWebView();

// HybridWebViewInitialized assumes Handler != null
if (Handler == null)
{
return;
}

HybridWebViewInitialized?.Invoke(this, new HybridWebViewInitializedEventArgs()
{
#if ANDROID || IOS || MACCATALYST || WINDOWS

Unchanged files with check annotations Beta

{
string contentType;
string fullUrl = url;

Check warning on line 100 in HybridWebView/Platforms/iOS/HybridWebViewHandler.iOS.cs

GitHub Actions / call-build-workflow / Build (windows-latest)

Converting null literal or possible null value to non-nullable type.

Check warning on line 100 in HybridWebView/Platforms/iOS/HybridWebViewHandler.iOS.cs

GitHub Actions / call-build-workflow / Build (macos-14)

Converting null literal or possible null value to non-nullable type.
url = QueryStringHelper.RemovePossibleQueryString(url);
if (new Uri(url) is Uri uri && HybridWebView.AppOriginUri.IsBaseOf(uri))
// Check to see if the request is a proxy request.
if (relativePath == HybridWebView.ProxyRequestPath)
{
var args = new HybridWebViewProxyEventArgs(fullUrl);

Check warning on line 133 in HybridWebView/Platforms/iOS/HybridWebViewHandler.iOS.cs

GitHub Actions / call-build-workflow / Build (windows-latest)

Possible null reference argument for parameter 'fullUrl' in 'HybridWebViewProxyEventArgs.HybridWebViewProxyEventArgs(string fullUrl)'.

Check warning on line 133 in HybridWebView/Platforms/iOS/HybridWebViewHandler.iOS.cs

GitHub Actions / call-build-workflow / Build (macos-14)

Possible null reference argument for parameter 'fullUrl' in 'HybridWebViewProxyEventArgs.HybridWebViewProxyEventArgs(string fullUrl)'.
await hwv.OnProxyRequestMessage(args);
{
string contentType;
string fullUrl = url;

Check warning on line 99 in HybridWebView/Platforms/MacCatalyst/HybridWebViewHandler.MacCatalyst.cs

GitHub Actions / call-build-workflow / Build (windows-latest)

Converting null literal or possible null value to non-nullable type.

Check warning on line 99 in HybridWebView/Platforms/MacCatalyst/HybridWebViewHandler.MacCatalyst.cs

GitHub Actions / call-build-workflow / Build (macos-14)

Converting null literal or possible null value to non-nullable type.
url = QueryStringHelper.RemovePossibleQueryString(url);
if (new Uri(url) is Uri uri && HybridWebView.AppOriginUri.IsBaseOf(uri))
// Check to see if the request is a proxy request.
if (relativePath == HybridWebView.ProxyRequestPath)
{
var args = new HybridWebViewProxyEventArgs(fullUrl);

Check warning on line 132 in HybridWebView/Platforms/MacCatalyst/HybridWebViewHandler.MacCatalyst.cs

GitHub Actions / call-build-workflow / Build (windows-latest)

Possible null reference argument for parameter 'fullUrl' in 'HybridWebViewProxyEventArgs.HybridWebViewProxyEventArgs(string fullUrl)'.

Check warning on line 132 in HybridWebView/Platforms/MacCatalyst/HybridWebViewHandler.MacCatalyst.cs

GitHub Actions / call-build-workflow / Build (macos-14)

Possible null reference argument for parameter 'fullUrl' in 'HybridWebViewProxyEventArgs.HybridWebViewProxyEventArgs(string fullUrl)'.
await hwv.OnProxyRequestMessage(args);
// Check to see if the request is a proxy request.
if (relativePath == HybridWebView.ProxyRequestPath)
{
var args = new HybridWebViewProxyEventArgs(fullUrl);

Check warning on line 51 in HybridWebView/Platforms/Android/AndroidHybridWebViewClient.cs

GitHub Actions / call-build-workflow / Build (windows-latest)

Possible null reference argument for parameter 'fullUrl' in 'HybridWebViewProxyEventArgs.HybridWebViewProxyEventArgs(string fullUrl)'.

Check warning on line 51 in HybridWebView/Platforms/Android/AndroidHybridWebViewClient.cs

GitHub Actions / call-build-workflow / Build (macos-14)

Possible null reference argument for parameter 'fullUrl' in 'HybridWebViewProxyEventArgs.HybridWebViewProxyEventArgs(string fullUrl)'.
// TODO: Don't block async. Consider making this an async call, and then calling DidFinish when done
webView.OnProxyRequestMessage(args).Wait();