fix: Home start shows Prepare or a blank window, and Prepare opens slowly (#15878)

This commit is contained in:
Kris Austin
2026-09-26 14:23:52 -03:00
committed by GitHub
parent e77d179bbe
commit 237cd10eb5
16 changed files with 421 additions and 342 deletions
+7 -3
View File
@@ -10,6 +10,7 @@
#include <wx/webviewarchivehandler.h>
#include <wx/webviewfshandler.h>
#include <wx/weakref.h>
#if wxUSE_WEBVIEW_EDGE
#include <wx/msw/webview_edge.h>
#elif defined(__WXMAC__)
@@ -235,7 +236,9 @@ class FakeWebView : public wxWebView
wxDEFINE_EVENT(EVT_WEBVIEW_RECREATED, wxCommandEvent);
static std::vector<wxWebView*> g_webviews;
static std::vector<wxWebView*> g_delay_webviews;
// Webviews waiting for their script handler while another one is added; adding it yields, so a
// view can be destroyed while it waits.
static std::vector<wxWeakRef<wxWebView>> g_delay_webviews;
class WebViewRef : public wxObjectRefData
{
@@ -340,8 +343,9 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
addScriptMessageHandler(webView);
while (!g_delay_webviews.empty()) {
auto views = std::move(g_delay_webviews);
for (auto wv : views)
addScriptMessageHandler(wv);
for (const wxWeakRef<wxWebView>& wv : views)
if (wv)
addScriptMessageHandler(wv.get());
}
}
#ifndef __WIN32__