diff --git a/src/slic3r/GUI/PluginWebDialog.cpp b/src/slic3r/GUI/PluginWebDialog.cpp index d89aac7270..b8e0a7756b 100644 --- a/src/slic3r/GUI/PluginWebDialog.cpp +++ b/src/slic3r/GUI/PluginWebDialog.cpp @@ -139,19 +139,32 @@ void PluginWebDialog::destroy_for_plugin(PluginWebDialog* dialog) void PluginWebDialog::on_bootstrap_event(wxWebViewEvent& event) { - // The first bootstrap load (or its error) triggers the swap to plugin HTML; - // the resulting plugin-page load is ignored (guarded by m_content_loaded). - load_plugin_content(); + // The first bootstrap load (or its error) triggers the swap to plugin HTML. + if (!m_content_loaded) + load_plugin_content(); +#ifndef __WXMSW__ + // WebKit reloads the SetPage base URL rather than the injected page, so a later main-frame + // load that is not our own SetPage is a browser reload, and the plugin HTML has to be put + // back. A post-load error only ever means a failed subresource. WebView2 reloads SetPage + // content from its own history entry, and reports in-document navigation as a load, so + // MSW needs neither the re-injection nor a guard against it. + else if (event.GetEventType() == wxEVT_WEBVIEW_LOADED) { + if (m_own_page_load) + m_own_page_load = false; + else + load_plugin_content(); + } +#endif event.Skip(); } void PluginWebDialog::load_plugin_content() { - if (m_content_loaded) - return; m_content_loaded = true; - if (wxWebView* wv = browser()) + if (wxWebView* wv = browser()) { + m_own_page_load = true; wv->SetPage(wxString::FromUTF8(m_html), web_base_url()); + } } void PluginWebDialog::on_script_message(const nlohmann::json& payload) diff --git a/src/slic3r/GUI/PluginWebDialog.hpp b/src/slic3r/GUI/PluginWebDialog.hpp index 05f77f5148..50dd276621 100644 --- a/src/slic3r/GUI/PluginWebDialog.hpp +++ b/src/slic3r/GUI/PluginWebDialog.hpp @@ -72,6 +72,7 @@ private: std::string m_html; bool m_content_loaded{false}; + bool m_own_page_load{false}; // a SetPage of the plugin HTML is in flight bool m_open{true}; bool m_close_fired{false}; std::optional m_result;