From 7bc73be0c9ad26b1e82bccdfe934cf90d86ab4f3 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Mon, 22 Apr 2024 17:47:06 +0200 Subject: [PATCH] Runscript only if tab with webview is shown. Fixes premature script running on sys_color_changed. This can be solved more elegantly. --- src/slic3r/GUI/WebViewDialog.cpp | 3 ++- src/slic3r/GUI/WebViewDialog.hpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index 847f7e7313..69231c3876 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -168,6 +168,7 @@ void WebViewPanel::load_error_page() void WebViewPanel::on_show(wxShowEvent& evt) { + m_shown = evt.IsShown(); if (evt.IsShown() && m_load_default_url) { m_load_default_url = false; load_url(m_default_url); @@ -310,7 +311,7 @@ void WebViewPanel::on_tools_clicked(wxCommandEvent& WXUNUSED(evt)) void WebViewPanel::run_script(const wxString& javascript) { - if (!m_browser) + if (!m_browser || !m_shown) return; // Remember the script we run in any case, so the next time the user opens // the "Run Script" dialog box, it is shown there for convenient updating. diff --git a/src/slic3r/GUI/WebViewDialog.hpp b/src/slic3r/GUI/WebViewDialog.hpp index 3585e45d1a..f25ec21399 100644 --- a/src/slic3r/GUI/WebViewDialog.hpp +++ b/src/slic3r/GUI/WebViewDialog.hpp @@ -87,6 +87,7 @@ protected: //DECLARE_EVENT_TABLE() bool m_load_error_page { false }; + bool m_shown { false }; }; class ConnectRequestHandler