From 761417f1bf7edd3e0fe81fad8dea3ced7c7de2c9 Mon Sep 17 00:00:00 2001 From: ZdDroid <43038779+ZdDroid@users.noreply.github.com> Date: Thu, 24 Aug 2023 18:30:32 +0800 Subject: [PATCH] =?UTF-8?q?Fixed=20crashes=20caused=20by=20failed=20versio?= =?UTF-8?q?n=20checks=20=E4=BF=AE=E5=A4=8D:=E6=A3=80=E6=9F=A5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=A6=82=E7=8E=87=E5=B4=A9=E6=BA=83=20(#1903)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复:检查更新概率崩溃 Co-authored-by: ZdDroid <601865048@qq.com> --- src/slic3r/GUI/GUI_App.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 6ac1296184..21699ff659 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4118,18 +4118,27 @@ void GUI_App::check_new_version_sf(bool show_tips, int by_user) Http::get(version_check_url).on_error([&](std::string body, std::string error, unsigned http_status) { (void)body; BOOST_LOG_TRIVIAL(error) << format("Error getting: `%1%`: HTTP %2%, %3%", - version_check_url, + "check_new_version_sf", http_status, error); }) .timeout_connect(1) - .on_complete([&](std::string body, unsigned /* http_status */) { + .on_complete([&](std::string body, unsigned http_status ) { + //Http response OK + if (http_status != 200) + return; + boost::trim(body); // SoftFever: parse github release, ported from SS boost::property_tree::ptree root; - std::stringstream json_stream(body); - boost::property_tree::read_json(json_stream, root); + try { + std::stringstream json_stream(body); + boost::property_tree::read_json(json_stream, root); + } catch (const boost::property_tree::ptree_error &e) { + BOOST_LOG_TRIVIAL(error) << format("Error version json: `%1%`", e.what()); + return; + } bool i_am_pre = false; //at least two number, use '.' as separator. can be followed by -Az23 for prereleased and +Az42 for metadata std::regex matcher("[0-9]+\\.[0-9]+(\\.[0-9]+)*(-[A-Za-z0-9]+)?(\\+[A-Za-z0-9]+)?");