Fix the random crash at the startup on Macos&&Linux
don't do the post_init when adding script handler of webview Change-Id: I2c766c46bb67347286765dee539657b5efd7f64a
This commit is contained in:
parent
3dbdc40360
commit
c6f0c41213
|
@ -2307,7 +2307,7 @@ bool GUI_App::on_init_inner()
|
|||
//#ifdef __linux__
|
||||
// if (!m_post_initialized && m_opengl_initialized) {
|
||||
//#else
|
||||
if (!m_post_initialized) {
|
||||
if (!m_post_initialized && !m_adding_script_handler) {
|
||||
//#endif
|
||||
m_post_initialized = true;
|
||||
#ifdef WIN32
|
||||
|
|
|
@ -269,6 +269,8 @@ private:
|
|||
boost::thread m_sync_update_thread;
|
||||
bool enable_sync = false;
|
||||
|
||||
bool m_adding_script_handler { false };
|
||||
|
||||
public:
|
||||
bool OnInit() override;
|
||||
bool initialized() const { return m_initialized; }
|
||||
|
@ -458,6 +460,8 @@ public:
|
|||
//BBS
|
||||
void load_url(wxString url);
|
||||
void run_script(wxString js);
|
||||
bool is_adding_script_handler() { return m_adding_script_handler; }
|
||||
void set_adding_script_handler(bool status) { m_adding_script_handler = status; }
|
||||
|
||||
// Parameters extracted from the command line to be passed to GUI after initialization.
|
||||
GUI_InitParams* init_params { nullptr };
|
||||
|
|
|
@ -107,8 +107,12 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
|
|||
#ifndef __WIN32__
|
||||
Slic3r::GUI::wxGetApp().CallAfter([webView] {
|
||||
#endif
|
||||
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__
|
||||
});
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue