From a34bd74133e1b9192913601cd6ad7e0fc4504cc1 Mon Sep 17 00:00:00 2001 From: attila Date: Thu, 15 Aug 2024 18:39:58 +0200 Subject: [PATCH] Windows: WebBrowserComponent: Fix state handling when the component is invisible The handling of two state variables had to be adjusted. One is responsible for signalling that we navigated to a blank page due to the WebBrowserComponent becoming invisible. The other variable in the WebView2 implementation stores the URL that we should be navigating to once the WebView2 instance has been created. Prior to this commit navigating to the URL requested by goToURL could fail for two reasons: either because it was called before the underlying WebView2 instance was created, or because the WebBrowserComponent was not yet visible. --- modules/juce_gui_extra/misc/juce_WebBrowserComponent.cpp | 4 ++-- .../native/juce_WebBrowserComponent_windows.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/juce_gui_extra/misc/juce_WebBrowserComponent.cpp b/modules/juce_gui_extra/misc/juce_WebBrowserComponent.cpp index 3414e0d5eb..77a2c53381 100644 --- a/modules/juce_gui_extra/misc/juce_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_WebBrowserComponent.cpp @@ -644,9 +644,9 @@ void WebBrowserComponent::goToURL (const String& url, else lastPostData.reset(); - blankPageShown = false; - impl->goToURL (url, headers, postData); + + blankPageShown = false; } void WebBrowserComponent::stop() diff --git a/modules/juce_gui_extra/native/juce_WebBrowserComponent_windows.cpp b/modules/juce_gui_extra/native/juce_WebBrowserComponent_windows.cpp index b7752a9ff0..0d814a8a18 100644 --- a/modules/juce_gui_extra/native/juce_WebBrowserComponent_windows.cpp +++ b/modules/juce_gui_extra/native/juce_WebBrowserComponent_windows.cpp @@ -474,7 +474,7 @@ public: } else { - if (owner.unloadPageWhenHidden && ! owner.blankPageShown) + if (webView != nullptr && owner.unloadPageWhenHidden && ! owner.blankPageShown) { // when the component becomes invisible, some stuff like flash // carries on playing audio, so we need to force it onto a blank