FIX: [STUDIO-2631] call AddScriptMessageHandler queued
Change-Id: I6a71c2db3ed1b3d06931f53428a8d78881399b4d
This commit is contained in:
parent
e11c004de4
commit
0aea102bd3
|
@ -128,6 +128,7 @@ class FakeWebView : public wxWebView
|
||||||
wxDEFINE_EVENT(EVT_WEBVIEW_RECREATED, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_WEBVIEW_RECREATED, wxCommandEvent);
|
||||||
|
|
||||||
static std::vector<wxWebView*> g_webviews;
|
static std::vector<wxWebView*> g_webviews;
|
||||||
|
static std::vector<wxWebView*> g_delay_webviews;
|
||||||
|
|
||||||
class WebViewRef : public wxObjectRefData
|
class WebViewRef : public wxObjectRefData
|
||||||
{
|
{
|
||||||
|
@ -193,16 +194,27 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
|
||||||
WKWebView * wkWebView = (WKWebView *) webView->GetNativeBackend();
|
WKWebView * wkWebView = (WKWebView *) webView->GetNativeBackend();
|
||||||
Slic3r::GUI::WKWebView_setTransparentBackground(wkWebView);
|
Slic3r::GUI::WKWebView_setTransparentBackground(wkWebView);
|
||||||
#endif
|
#endif
|
||||||
|
auto addScriptMessageHandler = [] (wxWebView *webView) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": begin to add script message handler for wx.";
|
||||||
|
Slic3r::GUI::wxGetApp().set_adding_script_handler(true);
|
||||||
|
if (!webView->AddScriptMessageHandler("wx"))
|
||||||
|
wxLogError("Could not add script message handler");
|
||||||
|
Slic3r::GUI::wxGetApp().set_adding_script_handler(false);
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": finished add script message handler for wx.";
|
||||||
|
};
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
webView->CallAfter([webView] {
|
webView->CallAfter([webView, addScriptMessageHandler] {
|
||||||
#endif
|
#endif
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": begin to add script message handler for wx.";
|
if (Slic3r::GUI::wxGetApp().is_adding_script_handler()) {
|
||||||
Slic3r::GUI::wxGetApp().set_adding_script_handler(true);
|
g_delay_webviews.push_back(webView);
|
||||||
if (!webView->AddScriptMessageHandler("wx"))
|
} else {
|
||||||
wxLogError("Could not add script message handler");
|
addScriptMessageHandler(webView);
|
||||||
Slic3r::GUI::wxGetApp().set_adding_script_handler(false);
|
while (!g_delay_webviews.empty()) {
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": finished add script message handler for wx.";
|
auto views = std::move(g_delay_webviews);
|
||||||
|
for (auto wv : views)
|
||||||
|
addScriptMessageHandler(wv);
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue