Sleep before closing dialog.

+ fix of double loading first url.
This commit is contained in:
Lukas Matena 2024-12-18 12:57:48 +01:00
parent 7a01f7b26d
commit 765ddd7594

View File

@ -15,6 +15,7 @@
#include <libslic3r/PresetBundle.hpp> // IWYU pragma: keep #include <libslic3r/PresetBundle.hpp> // IWYU pragma: keep
#include <thread>
#include <wx/webview.h> #include <wx/webview.h>
#include <wx/display.h> #include <wx/display.h>
@ -80,7 +81,7 @@ WebViewDialog::WebViewDialog(wxWindow* parent, const wxString& url, const wxStri
topsizer->Add(text, 0, wxALIGN_LEFT | wxBOTTOM, 10); topsizer->Add(text, 0, wxALIGN_LEFT | wxBOTTOM, 10);
return; return;
} }
WebView::webview_create(m_browser, this, GUI::format_wxstr("file://%1%/web/%2%.html", boost::filesystem::path(resources_dir()).generic_string(), m_loading_html), m_script_message_hadler_names); WebView::webview_create(m_browser, this, url, m_script_message_hadler_names);
if (Utils::ServiceConfig::instance().webdev_enabled()) { if (Utils::ServiceConfig::instance().webdev_enabled()) {
m_browser->EnableContextMenu(); m_browser->EnableContextMenu();
@ -139,7 +140,6 @@ WebViewDialog::WebViewDialog(wxWindow* parent, const wxString& url, const wxStri
Bind(wxEVT_CLOSE_WINDOW, ([this](wxCloseEvent& evt) { EndModal(wxID_CANCEL); })); Bind(wxEVT_CLOSE_WINDOW, ([this](wxCloseEvent& evt) { EndModal(wxID_CANCEL); }));
m_browser->LoadURL(url);
#ifdef DEBUG_URL_PANEL #ifdef DEBUG_URL_PANEL
m_url->SetLabelText(url); m_url->SetLabelText(url);
#endif #endif
@ -706,6 +706,7 @@ void LoginWebViewDialog::on_navigation_request(wxWebViewEvent &evt)
delete_cookies(m_browser, "https://appleid.apple.com"); delete_cookies(m_browser, "https://appleid.apple.com");
delete_cookies(m_browser, "https://facebook.com"); delete_cookies(m_browser, "https://facebook.com");
evt.Veto(); evt.Veto();
std::this_thread::sleep_for(std::chrono::milliseconds(500));
m_ret_val = into_u8(url); m_ret_val = into_u8(url);
EndModal(wxID_OK); EndModal(wxID_OK);
} else if (url.Find(L"accounts.google.com") != wxNOT_FOUND } else if (url.Find(L"accounts.google.com") != wxNOT_FOUND