diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 666e6ce467..c484bd9320 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1046,7 +1046,8 @@ void GUI_App::post_init() bool cw_showed = this->config_wizard_startup(); std::string http_url = get_http_url(app_config->get_country_code()); - this->preset_updater->sync(http_url, preset_bundle); + std::string language = GUI::into_u8(current_language_code()); + this->preset_updater->sync(http_url, language, preset_bundle); //BBS: check new version this->check_new_version(); @@ -1541,7 +1542,7 @@ void GUI_App::init_networking_callbacks() } } } - }); + }); } ); @@ -2567,7 +2568,7 @@ void GUI_App::recreate_GUI(const wxString& msg_name) // }); m_is_recreating_gui = false; - + CallAfter([this]() { mainframe->refresh_plugin_tips(); }); @@ -2952,7 +2953,7 @@ std::string GUI_App::handle_web_request(std::string cmd) } else if (command_str.compare("begin_network_plugin_download") == 0) { CallAfter([this] { wxGetApp().ShowDownNetPluginDlg(); }); - } + } else if (command_str.compare("get_web_shortcut") == 0) { if (root.get_child_optional("key_event") != boost::none) { pt::ptree key_event_node = root.get_child("key_event"); diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index 8e12dfc1bb..683785a4e3 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -227,7 +227,7 @@ struct PresetUpdater::priv void parse_version_string(const std::string& body) const; void sync_resources(std::string http_url, std::map &resources); void sync_config(std::string http_url, const VendorMap vendors); - void sync_tooltip(std::string http_url); + void sync_tooltip(std::string http_url, std::string language); //BBS: refine preset update logic bool install_bundles_rsrc(std::vector bundles, bool snapshot) const; @@ -268,36 +268,38 @@ void PresetUpdater::priv::set_download_prefs(AppConfig *app_config) // Downloads a file (http get operation). Cancels if the Updater is being destroyed. bool PresetUpdater::priv::get_file(const std::string &url, const fs::path &target_path) const { - bool res = false; - fs::path tmp_path = target_path; - tmp_path += format(".%1%%2%", get_current_pid(), TMP_EXTENSION); + bool res = false; + fs::path tmp_path = target_path; + tmp_path += format(".%1%%2%", get_current_pid(), TMP_EXTENSION); - BOOST_LOG_TRIVIAL(info) << format("[BBS Updater]download file `%1%`, stored to `%2%`, tmp path `%3%`", - url, - target_path.string(), - tmp_path.string()); + BOOST_LOG_TRIVIAL(info) << format("[BBS Updater]download file `%1%`, stored to `%2%`, tmp path `%3%`", + url, + target_path.string(), + tmp_path.string()); Slic3r::Http::get(url) - .on_progress([](Slic3r::Http::Progress, bool &cancel) { - if (cancel) { cancel = true; } - }) - .on_error([&](std::string body, std::string error, unsigned http_status) { - (void)body; - BOOST_LOG_TRIVIAL(error) << format("[BBS Updater]getting: `%1%`: http status %2%, %3%", - url, - http_status, - error); - }) - .on_complete([&](std::string body, unsigned /* http_status */) { - fs::fstream file(tmp_path, std::ios::out | std::ios::binary | std::ios::trunc); - file.write(body.c_str(), body.size()); - file.close(); - fs::rename(tmp_path, target_path); - res = true; - }) - .perform_sync(); + .on_progress([this](Slic3r::Http::Progress, bool &cancel_http) { + if (cancel) { + cancel_http = true; + } + }) + .on_error([&](std::string body, std::string error, unsigned http_status) { + (void)body; + BOOST_LOG_TRIVIAL(error) << format("[BBS Updater]getting: `%1%`: http status %2%, %3%", + url, + http_status, + error); + }) + .on_complete([&](std::string body, unsigned /* http_status */) { + fs::fstream file(tmp_path, std::ios::out | std::ios::binary | std::ios::trunc); + file.write(body.c_str(), body.size()); + file.close(); + fs::rename(tmp_path, target_path); + res = true; + }) + .perform_sync(); - return res; + return res; } //BBS: refine preset update logic @@ -494,7 +496,12 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::mapset_download_prefs(GUI::wxGetApp().app_config); if (!p->enabled_version_check && !p->enabled_config_update) { return; } @@ -1064,11 +1075,17 @@ void PresetUpdater::sync(std::string http_url, PresetBundle *preset_bundle) // into the closure (but perhaps the compiler can elide this). VendorMap vendors = preset_bundle->vendors; - p->thread = std::thread([this, vendors, http_url]() { + p->thread = std::thread([this, vendors, http_url, language]() { this->p->prune_tmps(); + if (p->cancel) + return; this->p->sync_version(); + if (p->cancel) + return; this->p->sync_config(http_url, std::move(vendors)); - this->p->sync_tooltip(http_url); + if (p->cancel) + return; + this->p->sync_tooltip(http_url, language); }); } diff --git a/src/slic3r/Utils/PresetUpdater.hpp b/src/slic3r/Utils/PresetUpdater.hpp index 8e949efbc5..4db6772849 100644 --- a/src/slic3r/Utils/PresetUpdater.hpp +++ b/src/slic3r/Utils/PresetUpdater.hpp @@ -26,7 +26,7 @@ public: ~PresetUpdater(); // If either version check or config updating is enabled, get the appropriate data in the background and cache it. - void sync(std::string http_url, PresetBundle *preset_bundle); + void sync(std::string http_url, std::string language, PresetBundle *preset_bundle); // If version check is enabled, check if chaced online slic3r version is newer, notify if so. void slic3r_update_notify();