From e44e1c1f191397ddbb6a4106059b4e011b67c63d Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Tue, 8 Nov 2022 13:36:28 +0800 Subject: [PATCH] FIX: video error message when lan ip missing Change-Id: I5adaa89e2631a4e7853d806a53f41da927cc0ea7 --- src/slic3r/GUI/MediaPlayCtrl.cpp | 16 ++++++++++++---- src/slic3r/GUI/wxMediaCtrl2.cpp | 5 +++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index 90935bf48..1eedec2fe 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -142,7 +142,7 @@ void MediaPlayCtrl::Play() m_button_play->SetIcon("media_stop"); SetStatus(_L("Initializing...")); - if (!m_lan_ip.empty()) { + if (!m_lan_ip.empty() && !m_lan_passwd.empty()) { m_url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd; m_last_state = MEDIASTATE_LOADING; SetStatus(_L("Loading...")); @@ -161,7 +161,7 @@ void MediaPlayCtrl::Play() m_cond.notify_all(); return; } - + if (m_lan_mode) { Stop(); SetStatus(m_lan_passwd.empty() @@ -172,7 +172,9 @@ void MediaPlayCtrl::Play() if (!m_tutk_support) { // not support tutk Stop(); - SetStatus(_L("Initialize failed (Not supported without remote video tunnel)!")); + SetStatus(m_lan_ip.empty() + ? _L("Initialize failed (Missing LAN ip of printer)!") + : _L("Initialize failed (Not supported by printer)!")); return; } @@ -335,7 +337,13 @@ void MediaPlayCtrl::ToggleStream() agent->get_camera_url(m_machine, [this, m = m_machine](std::string url) { BOOST_LOG_TRIVIAL(info) << "camera_url: " << url; CallAfter([this, m, url] { - if (m != m_machine || url.empty()) return; + if (m != m_machine) return; + if (url.empty() || !boost::algorithm::starts_with(url, "bambu:///")) { + MessageDialog(this, wxString::Format(_L("Virtual camera initialize failed (%s)!"), url.empty() ? _L("Network unreachable") : from_u8(url)), _L("Information"), + wxICON_INFORMATION) + .ShowModal(); + return; + } std::string file_url = data_dir() + "/cameratools/url.txt"; boost::nowide::ofstream file(file_url); auto url2 = encode_path((url + "&device=" + m).c_str()); diff --git a/src/slic3r/GUI/wxMediaCtrl2.cpp b/src/slic3r/GUI/wxMediaCtrl2.cpp index a4d2bed12..fd683f9d7 100644 --- a/src/slic3r/GUI/wxMediaCtrl2.cpp +++ b/src/slic3r/GUI/wxMediaCtrl2.cpp @@ -50,10 +50,11 @@ void wxMediaCtrl2::Load(wxURI url) } { wxRegKey key1(wxRegKey::HKCR, L"CLSID\\" CLSID_BAMBU_SOURCE L"\\InProcServer32"); - wxString path = key1.QueryDefaultValue(); + wxString path = key1.Exists() ? key1.QueryDefaultValue() : wxString{}; wxRegKey key2(wxRegKey::HKCR, "bambu"); wxString clsid; - key2.QueryRawValue("Source Filter", clsid); + if (key2.Exists()) + key2.QueryRawValue("Source Filter", clsid); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": clsid %1% path %2%") % clsid % path; if (path.empty() || !wxFile::Exists(path) || clsid != CLSID_BAMBU_SOURCE) {