diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index 8b752b5716..7869662d7c 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -140,6 +140,8 @@ MediaPlayCtrl::~MediaPlayCtrl() while (!m_thread.try_join_for(boost::chrono::milliseconds(10))) { wxEventLoopBase::GetActive()->Yield(); } + + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": " << this; } void MediaPlayCtrl::SetMachineObject(MachineObject* obj) @@ -335,7 +337,12 @@ void MediaPlayCtrl::Play() if (agent) { std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""}; agent->get_camera_url(m_machine + "|" + m_dev_ver + "|" + protocols[m_remote_proto], - [this, m = m_machine, v = agent_version, dv = m_dev_ver](std::string url) { + [this, m = m_machine, v = agent_version, dv = m_dev_ver, token = std::weak_ptr(m_token)](std::string url) { + if (token.expired()) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": token has been expired"; + return; + } + if (boost::algorithm::starts_with(url, "bambu:///")) { url += "&device=" + into_u8(m); url += "&net_ver=" + v; diff --git a/src/slic3r/GUI/MediaPlayCtrl.h b/src/slic3r/GUI/MediaPlayCtrl.h index 7eba8e37ce..bb4e8e448f 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.h +++ b/src/slic3r/GUI/MediaPlayCtrl.h @@ -72,6 +72,9 @@ private: static const wxMediaState MEDIASTATE_LOADING = (wxMediaState) 5; static const wxMediaState MEDIASTATE_BUFFERING = (wxMediaState) 6; + // token + std::shared_ptr m_token = std::make_shared(0); + wxMediaCtrl2 * m_media_ctrl; wxMediaState m_last_state = MEDIASTATE_IDLE; std::string m_machine;