FIX:fixed download address splicing failure

Change-Id: I41b3f822aac95be86bf05db40dee54da133e6acf
This commit is contained in:
tao wang 2023-05-21 13:44:13 +08:00 committed by Lane.Wei
parent 9dd33e599f
commit 57873e6e59
4 changed files with 14 additions and 13 deletions

View file

@ -1006,7 +1006,6 @@ void GUI_App::post_init()
bool switch_to_3d = false;
if (!this->init_params->input_files.empty()) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", init with input files, size %1%, input_gcode %2%")
%this->init_params->input_files.size() %this->init_params->input_gcode;
@ -1027,7 +1026,7 @@ void GUI_App::post_init()
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("download_url %1%") % download_url;
if (!download_url.empty()) {
request_model_download(download_url);
request_model_download(from_u8(download_url));
}
}
@ -3897,7 +3896,7 @@ void GUI_App::handle_script_message(std::string msg)
}
}
void GUI_App::request_model_download(std::string url)
void GUI_App::request_model_download(wxString url)
{
if (plater_) {
plater_->request_model_download(url);

View file

@ -407,7 +407,7 @@ public:
int request_user_unbind(std::string dev_id);
std::string handle_web_request(std::string cmd);
void handle_script_message(std::string msg);
void request_model_download(std::string url);
void request_model_download(wxString url);
void download_project(std::string project_id);
void request_project_download(std::string project_id);
void request_open_project(std::string project_id);

View file

@ -6304,7 +6304,7 @@ void Plater::priv::on_action_request_model_id(wxCommandEvent& evt)
{
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received import model id event\n" ;
if (q != nullptr) {
q->import_model_id(evt.GetString().ToStdString());
q->import_model_id(evt.GetString());
}
}
@ -7833,10 +7833,11 @@ int Plater::save_project(bool saveAs)
}
//BBS import model by model id
void Plater::import_model_id(const std::string& download_info)
void Plater::import_model_id(wxString download_info)
{
std::string download_origin_url = wxGetApp().url_decode(download_info);
//std::string download_origin_url = wxGetApp().url_decode(download_info.ToStdString());
std::string download_origin_url = download_info.ToStdString();
std::string download_url;
std::string filename;
@ -7847,7 +7848,6 @@ void Plater::import_model_id(const std::string& download_info)
download_url = origin_array[0];
filename = origin_array[1];
}
else if (!download_origin_url.empty()) {
@ -7954,7 +7954,8 @@ void Plater::import_model_id(const std::string& download_info)
}
//target_path /= (boost::format("%1%_%2%.3mf") % filename % unique).str();
target_path /= filename.c_str();
target_path /= fs::path(wxString(filename));
fs::path tmp_path = target_path;
tmp_path += format(".%1%", ".download");
@ -8006,6 +8007,7 @@ void Plater::import_model_id(const std::string& download_info)
if (import_thread.joinable())
import_thread.join();
dlg.Hide();
dlg.Close();
if (download_ok) {
BOOST_LOG_TRIVIAL(trace) << "import_model_id: target_path = " << target_path.string();
@ -8021,7 +8023,7 @@ void Plater::import_model_id(const std::string& download_info)
}
// show save new project
p->set_project_filename(wxString::FromUTF8(filename));
p->set_project_filename(wxString(filename));
}
else {
wxMessageBox(msg);
@ -8035,7 +8037,7 @@ void Plater::download_project(const wxString& project_id)
return;
}
void Plater::request_model_download(std::string url)
void Plater::request_model_download(wxString url)
{
wxCommandEvent* event = new wxCommandEvent(EVT_IMPORT_MODEL_ID);
event->SetString(url);

View file

@ -212,9 +212,9 @@ public:
void load_project(wxString const & filename = "", wxString const & originfile = "-");
int save_project(bool saveAs = false);
//BBS download project by project id
void import_model_id(const std::string& download_info);
void import_model_id(wxString download_info);
void download_project(const wxString& project_id);
void request_model_download(std::string url);
void request_model_download(wxString url);
void request_download_project(std::string project_id);
// BBS: check snapshot
bool up_to_date(bool saved, bool backup);