mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-20 13:17:54 -06:00
FIX: [STUDIO-1033] rm webview script handler on webview destory
Change-Id: I2e9390dfaad46da9e158a43026ef872aaf88d589
This commit is contained in:
parent
2a1f8af62e
commit
bda92795bb
1 changed files with 14 additions and 3 deletions
|
@ -6,6 +6,8 @@
|
||||||
#include <wx/webviewfshandler.h>
|
#include <wx/webviewfshandler.h>
|
||||||
#if wxUSE_WEBVIEW_EDGE
|
#if wxUSE_WEBVIEW_EDGE
|
||||||
#include <wx/msw/webview_edge.h>
|
#include <wx/msw/webview_edge.h>
|
||||||
|
#elif defined(__WXMAC__)
|
||||||
|
#include <wx/osx/webview_webkit.h>
|
||||||
#endif
|
#endif
|
||||||
#include <wx/uri.h>
|
#include <wx/uri.h>
|
||||||
#if defined(__WIN32__) || defined(__WXMAC__)
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
|
@ -75,6 +77,16 @@ private:
|
||||||
wxString pendingUserAgent;
|
wxString pendingUserAgent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#elif defined __WXOSX__
|
||||||
|
|
||||||
|
class WebViewWebKit : public wxWebViewWebKit
|
||||||
|
{
|
||||||
|
~WebViewWebKit() override
|
||||||
|
{
|
||||||
|
RemoveScriptMessageHandler("wx");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class FakeWebView : public wxWebView
|
class FakeWebView : public wxWebView
|
||||||
|
@ -152,6 +164,8 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
wxWebView* webView = new WebViewEdge;
|
wxWebView* webView = new WebViewEdge;
|
||||||
|
#elif defined(__WXOSX__)
|
||||||
|
wxWebView *webView = new WebViewWebKit;
|
||||||
#else
|
#else
|
||||||
auto webView = wxWebView::New();
|
auto webView = wxWebView::New();
|
||||||
#endif
|
#endif
|
||||||
|
@ -184,9 +198,6 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
|
||||||
#endif
|
#endif
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": begin to add script message handler for wx.";
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": begin to add script message handler for wx.";
|
||||||
Slic3r::GUI::wxGetApp().set_adding_script_handler(true);
|
Slic3r::GUI::wxGetApp().set_adding_script_handler(true);
|
||||||
webView->Bind(wxEVT_DESTROY, [webView] (auto & e) {
|
|
||||||
webView->RemoveScriptMessageHandler("wx");
|
|
||||||
});
|
|
||||||
if (!webView->AddScriptMessageHandler("wx"))
|
if (!webView->AddScriptMessageHandler("wx"))
|
||||||
wxLogError("Could not add script message handler");
|
wxLogError("Could not add script message handler");
|
||||||
Slic3r::GUI::wxGetApp().set_adding_script_handler(false);
|
Slic3r::GUI::wxGetApp().set_adding_script_handler(false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue