Skip to content

Commit

Permalink
Windows: Fix rare crash when creating and destroying WebBrowserCompon…
Browse files Browse the repository at this point in the history
…ent instances
  • Loading branch information
szarvas committed Jul 15, 2024
1 parent b35688d commit ae23783
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,12 @@ class WebBrowserComponent::Impl::Platform::WebView2 final : public WebBrowserCom

~WebView2() override
{
if (webView2ConstructionHelper.webView2BeingCreated == this)
webView2ConstructionHelper.webView2BeingCreated = nullptr;

webView2ConstructionHelper.viewsWaitingForCreation.erase (this);

cancelPendingUpdate();
removeEventHandlers();
closeWebView();
}
Expand Down Expand Up @@ -1022,8 +1028,6 @@ class WebBrowserComponent::Impl::Platform::WebView2 final : public WebBrowserCom
webView2ConstructionHelper.viewsWaitingForCreation.erase (this);
webView2ConstructionHelper.webView2BeingCreated = this;

WeakReference<WebView2> weakThis (this);

webViewHandle.environment->CreateCoreWebView2Controller ((HWND) peer->getNativeHandle(),
Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler> (
[weakThis = WeakReference<WebView2> { this }] (HRESULT, ICoreWebView2Controller* controller) -> HRESULT
Expand Down

0 comments on commit ae23783

Please sign in to comment.