diff --git a/src/slic3r/GUI/BindDialog.cpp b/src/slic3r/GUI/BindDialog.cpp index d24853fc6..b7d4731ca 100644 --- a/src/slic3r/GUI/BindDialog.cpp +++ b/src/slic3r/GUI/BindDialog.cpp @@ -570,7 +570,8 @@ wxString get_fail_reason(int code) { EndModal(wxID_OK); MessageDialog msg_wingow(nullptr, _L("Log in successful."), "", wxAPPLY | wxOK); - if (msg_wingow.ShowModal() == wxOK) { return; } + msg_wingow.ShowModal(); + if(m_machine_info) wxGetApp().on_start_subscribe_again(m_machine_info->dev_id); } void BindMachineDialog::on_bind_printer(wxCommandEvent &event) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 6ff4c75ed..c53339372 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2221,6 +2221,25 @@ void GUI_App::update_http_extra_header() m_agent->set_extra_http_header(extra_headers); } +void GUI_App::on_start_subscribe_again(std::string dev_id) +{ + auto start_subscribe_timer = new wxTimer(this, wxID_ANY); + Bind(wxEVT_TIMER, [this, start_subscribe_timer, dev_id](auto& e) { + Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); + if (!dev) return; + MachineObject* obj = dev->get_selected_machine(); + if (!obj) return; + + if ( (dev_id == obj->dev_id) && obj->is_connecting() ) { + if(wxGetApp().getAgent()) wxGetApp().getAgent()->set_user_selected_machine(dev_id); + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": dev_id=" << obj->dev_id; + } + + start_subscribe_timer->Stop(); + }); + start_subscribe_timer->Start(4000, wxTIMER_ONE_SHOT); +} + std::string GUI_App::get_local_models_path() { std::string local_path = ""; diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 9f5c6d548..0a105061e 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -297,6 +297,8 @@ private: boost::thread m_check_network_thread; public: + //try again when subscription fails + void on_start_subscribe_again(std::string dev_id); void check_filaments_in_blacklist(std::string tag_supplier, std::string tag_material, bool& in_blacklist, std::string& action, std::string& info); std::string get_local_models_path(); bool OnInit() override;