Fix macOS WebView script-handler cleanup after wxWidgets 3.3 upgrade

Commit ed88cbe removed `new WebViewWebKit` on macOS because wx 3.3
dropped the no-arg wxWebViewWebKit constructor, falling through to
wxWebView::New(). That bypassed the WebViewWebKit destructor that calls
RemoveScriptMessageHandler("wx"), reintroducing the WebKit teardown bug
the subclass was added to fix.

Restore the macOS-specific subclass path by adding a constructor that
forwards to the wx 3.3 wxWebViewConfiguration-based ctor.
This commit is contained in:
SoftFever
2026-03-30 11:53:48 +08:00
parent c3f52bb3ca
commit d62aa42e61

View File

@@ -173,6 +173,12 @@ private:
class WebViewWebKit : public wxWebViewWebKit
{
public:
WebViewWebKit()
: wxWebViewWebKit(wxWebView::NewConfiguration(wxWebViewBackendWebKit))
{
}
~WebViewWebKit() override
{
RemoveScriptMessageHandler("wx");
@@ -257,6 +263,8 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
#ifdef __WIN32__
wxWebView* webView = new WebViewEdge;
#elif defined(__WXOSX__)
wxWebView* webView = new WebViewWebKit;
#else
auto webView = wxWebView::New();
#endif