From dd792048a072408d3ec6b6ec2839887757a24376 Mon Sep 17 00:00:00 2001 From: Stone Li Date: Wed, 15 Feb 2023 08:56:31 +0800 Subject: [PATCH] ENH: do not block GUI when downloading hms file Change-Id: I2175c86caba66c54e8a708a402bc3595e1e77ac9 Signed-off-by: Stone Li --- src/slic3r/GUI/HMS.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/slic3r/GUI/HMS.cpp b/src/slic3r/GUI/HMS.cpp index 2bb7a78b3..87c5257a9 100644 --- a/src/slic3r/GUI/HMS.cpp +++ b/src/slic3r/GUI/HMS.cpp @@ -248,26 +248,27 @@ wxString HMSQuery::query_print_error_msg(int print_error) int HMSQuery::check_hms_info() { - int result = 0; - bool download_new_hms_info = true; - - // load local hms json file - std::string version = ""; - if (load_from_local(version) == 0) { - BOOST_LOG_TRIVIAL(info) << "HMS: check_hms_info current version = " << version; - std::string new_version; - get_hms_info_version(new_version); - BOOST_LOG_TRIVIAL(info) << "HMS: check_hms_info latest version = " << new_version; - if (!version.empty() && version == new_version) { - download_new_hms_info = false; + boost::thread check_thread = boost::thread([this] { + bool download_new_hms_info = true; + // load local hms json file + std::string version = ""; + if (load_from_local(version) == 0) { + BOOST_LOG_TRIVIAL(info) << "HMS: check_hms_info current version = " << version; + std::string new_version; + get_hms_info_version(new_version); + BOOST_LOG_TRIVIAL(info) << "HMS: check_hms_info latest version = " << new_version; + if (!version.empty() && version == new_version) { + download_new_hms_info = false; + } } - } - BOOST_LOG_TRIVIAL(info) << "HMS: check_hms_info need download new hms info = " << download_new_hms_info; - // download if version is update - if (download_new_hms_info) { - result = download_hms_info(); - } - return result; + BOOST_LOG_TRIVIAL(info) << "HMS: check_hms_info need download new hms info = " << download_new_hms_info; + // download if version is update + if (download_new_hms_info) { + download_hms_info(); + } + return; + }); + return 0; } std::string get_hms_wiki_url(std::string error_code)