Runscript only if tab with webview is shown.

Fixes premature script running on sys_color_changed. This can be solved more elegantly.
This commit is contained in:
David Kocik 2024-04-22 17:47:06 +02:00
parent b05d438fc6
commit 7bc73be0c9
2 changed files with 3 additions and 1 deletions

View File

@ -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.

View File

@ -87,6 +87,7 @@ protected:
//DECLARE_EVENT_TABLE()
bool m_load_error_page { false };
bool m_shown { false };
};
class ConnectRequestHandler