diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 58724f62..a2a53a5b 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -5408,8 +5408,6 @@ std::string GUI_App::handle_web_request(std::string cmd) boost::optional sequence_id = root.get_optional("sequence_id"); boost::optional command = root.get_optional("command"); - - wxString strInput = cmd; if (command.has_value()) { @@ -6221,7 +6219,7 @@ std::string GUI_App::handle_web_request(std::string cmd) wxString strJS = wxString::Format("window.handleStudioCmd('%s');", commandJson.dump()); wxGetApp().CallAfter([this, strJS] { run_script(strJS.ToStdString()); }); } else if (command_str.compare("set_deviceAdd_end") == 0) { - json printersData = json::parse(strInput); + json printersData = json::parse(cmd); json selectedPrintersJson = printersData["selected_printers"]; for (auto it = selectedPrintersJson.begin(); it != selectedPrintersJson.end(); ++it) { @@ -6650,7 +6648,7 @@ void GUI_App::on_http_error(wxCommandEvent &evt) wxString result; if (status >= 400 && status < 500) { try { - json j = json::parse(evt.GetString()); + json j = json::parse(evt.GetString().ToStdString()); if (j.contains("code")) { if (!j["code"].is_null()) code = j["code"].get(); diff --git a/src/slic3r/GUI/ModelMall.cpp b/src/slic3r/GUI/ModelMall.cpp index dd8ad547..d4ef62df 100644 --- a/src/slic3r/GUI/ModelMall.cpp +++ b/src/slic3r/GUI/ModelMall.cpp @@ -123,10 +123,10 @@ namespace GUI { void ModelMallDialog::OnScriptMessage(wxWebViewEvent& evt) { try { - wxString strInput = evt.GetString(); + std::string strInput = evt.GetString().ToStdString(); json j = json::parse(strInput); - wxString strCmd = j["command"]; + std::string strCmd = j["command"]; if(strCmd == "request_close_publish_window") { this->Hide(); diff --git a/src/slic3r/GUI/Project.cpp b/src/slic3r/GUI/Project.cpp index 1e8b783f..434b0e80 100644 --- a/src/slic3r/GUI/Project.cpp +++ b/src/slic3r/GUI/Project.cpp @@ -237,16 +237,16 @@ void ProjectPanel::on_navigated(wxWebViewEvent& event) void ProjectPanel::OnScriptMessage(wxWebViewEvent& evt) { try { - wxString strInput = evt.GetString(); + std::string strInput = evt.GetString().ToStdString(); json j = json::parse(strInput); - wxString strCmd = j["command"]; + std::string strCmd = j["command"]; if (strCmd == "open_3mf_accessory") { - wxString accessory_path = j["accessory_path"]; + std::string accessory_path = j["accessory_path"]; if (!accessory_path.empty()) { - std::string decode_path = wxGetApp().url_decode(accessory_path.ToStdString()); + std::string decode_path = wxGetApp().url_decode(accessory_path); fs::path path(decode_path); if (fs::exists(path)) { diff --git a/src/slic3r/GUI/WebDownPluginDlg.cpp b/src/slic3r/GUI/WebDownPluginDlg.cpp index 4d665b88..76c368d2 100644 --- a/src/slic3r/GUI/WebDownPluginDlg.cpp +++ b/src/slic3r/GUI/WebDownPluginDlg.cpp @@ -198,10 +198,10 @@ void DownPluginFrame::OnFullScreenChanged(wxWebViewEvent &evt) void DownPluginFrame::OnScriptMessage(wxWebViewEvent &evt) { try { - wxString strInput = evt.GetString(); + std::string strInput = evt.GetString().ToStdString(); json j = json::parse(strInput); - wxString strCmd = j["command"]; + std::string strCmd = j["command"]; if (strCmd == "Begin_Download_network_plugin") { wxGetApp().CallAfter([this] { DownloadPlugin(); }); diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index 5aae9568..4e2d2311 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -430,18 +430,18 @@ static std::vector Loc_GetMaterials(const std::string& materials) void GuideFrame::OnScriptMessage(wxWebViewEvent &evt) { try { - wxString strInput = evt.GetString(); + std::string strInput = evt.GetString().ToStdString(); BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;OnRecv:" << strInput.c_str(); json j = json::parse(strInput); - wxString strCmd = j["command"]; + std::string strCmd = j["command"]; BOOST_LOG_TRIVIAL(trace) << "GuideFrame::OnScriptMessage;Command:" << strCmd; if (strCmd == "close_page") { this->EndModal(wxID_CANCEL); } if (strCmd == "user_clause") { - wxString strAction = j["data"]["action"]; + std::string strAction = j["data"]["action"]; if (strAction == "refuse") { // CloseTheApp @@ -450,7 +450,7 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt) m_MainPtr->mainframe->Close(); // Refuse Clause, App quit immediately } } else if (strCmd == "user_private_choice") { - wxString strAction = j["data"]["action"]; + std::string strAction = j["data"]["action"]; if (strAction == "agree") { PrivacyUse = true; diff --git a/src/slic3r/GUI/print_manage/App/PrinterMgrView.cpp b/src/slic3r/GUI/print_manage/App/PrinterMgrView.cpp index 634eddf2..d79f1b79 100644 --- a/src/slic3r/GUI/print_manage/App/PrinterMgrView.cpp +++ b/src/slic3r/GUI/print_manage/App/PrinterMgrView.cpp @@ -325,29 +325,29 @@ void PrinterMgrView::OnScriptMessage(wxWebViewEvent& evt) return; } - wxString strInput = evt.GetString(); + std::string strInput = evt.GetString().ToStdString(); BOOST_LOG_TRIVIAL(trace) << "DeviceDialog::OnScriptMessage;OnRecv:" << strInput.c_str(); json j = json::parse(strInput); - wxString strCmd = j["command"]; + std::string strCmd = j["command"]; BOOST_LOG_TRIVIAL(trace) << "DeviceDialog::OnScriptMessage;Command:" << strCmd; if (strCmd == "send_gcode") { int plateIndex = j["plateIndex"]; - wxString ipAddress = j["ipAddress"]; - wxString uploadName = j["uploadName"]; + std::string ipAddress = j["ipAddress"]; + std::string uploadName = j["uploadName"]; bool oldPrinter = j["oldPrinter"]; int moonrakerPort = j["moonrakerPort"]; if (oldPrinter) { - std::string strIpAddr = ipAddress.ToStdString(); + std::string strIpAddr = ipAddress; RemotePrint::RemotePrinterManager::getInstance().setOldPrinterMap(strIpAddr); } if (moonrakerPort > 0) { - std::string strIpAddr = ipAddress.ToStdString(); + std::string strIpAddr = ipAddress; if (strIpAddr.find('(') != std::string::npos) { RemotePrint::RemotePrinterManager::getInstance().setKlipperPrinterMap(strIpAddr, moonrakerPort); @@ -369,7 +369,7 @@ void PrinterMgrView::OnScriptMessage(wxWebViewEvent& evt) } - RemotePrint::RemotePrinterManager::getInstance().pushUploadMultTasks(ipAddress.ToStdString(), uploadName.ToStdString(), gcodeFilePath, + RemotePrint::RemotePrinterManager::getInstance().pushUploadMultTasks(ipAddress, uploadName, gcodeFilePath, [this](std::string ip, float progress, double speed) { // BOOST_LOG_TRIVIAL(info) << "Progress: " << progress << "% for IP: " << ip; //进度发送太快会导致浏览器卡死,所以这里限制一下 @@ -491,9 +491,9 @@ void PrinterMgrView::OnScriptMessage(wxWebViewEvent& evt) scan_device(); } - else if (m_commandHandlers.find(strCmd.ToStdString()) != m_commandHandlers.end()) + else if (m_commandHandlers.find(strCmd) != m_commandHandlers.end()) { - m_commandHandlers[strCmd.ToStdString()](j); + m_commandHandlers[strCmd](j); } else if (strCmd == "req_device_move_direction") { diff --git a/src/slic3r/GUI/print_manage/App/SendToPrinter.cpp b/src/slic3r/GUI/print_manage/App/SendToPrinter.cpp index 1f96a334..e73a7681 100644 --- a/src/slic3r/GUI/print_manage/App/SendToPrinter.cpp +++ b/src/slic3r/GUI/print_manage/App/SendToPrinter.cpp @@ -315,10 +315,10 @@ void CxSentToPrinterDialog::UnregisterHandler(const std::string& command) void CxSentToPrinterDialog::OnScriptMessage(wxWebViewEvent& evt) { try { - wxString strInput = evt.GetString(); + std::string strInput = evt.GetString().ToStdString(); BOOST_LOG_TRIVIAL(trace) << "DeviceDialog::OnScriptMessage;OnRecv:" << strInput.c_str(); json j = json::parse(strInput); - wxString strCmd = j["command"]; + std::string strCmd = j["command"]; BOOST_LOG_TRIVIAL(trace) << "DeviceDialog::OnScriptMessage;Command:" << strCmd; if(strCmd == "forward_device_detail"){ wxPostEvent(this, wxCloseEvent(wxEVT_CLOSE_WINDOW)); @@ -343,8 +343,8 @@ void CxSentToPrinterDialog::OnScriptMessage(wxWebViewEvent& evt) - if (m_commandHandlers.find(strCmd.ToStdString()) != m_commandHandlers.end()) { - m_commandHandlers[strCmd.ToStdString()](j); + if (m_commandHandlers.find(strCmd) != m_commandHandlers.end()) { + m_commandHandlers[strCmd](j); } else { BOOST_LOG_TRIVIAL(trace) << "CxSentToPrinterDialog::OnScriptMessage;Unknown Command:" << strCmd; } @@ -1738,4 +1738,4 @@ int CxSentToPrinterDialog::load_machine_preset_data() } } // namespace GUI -} // namespace Slic3r \ No newline at end of file +} // namespace Slic3r