From 50e8e90dc8e68c0e7f4292af06590e1cef4cb77c Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Tue, 14 May 2024 11:53:14 +0800 Subject: [PATCH] FIX: update: add more logic to protect the file access previous json lacks information github: https://github.com/bambulab/BambuStudio/issues/4050 Change-Id: Ieca2a440f58f77f91caeac00576a38c861b26a5b --- src/slic3r/Utils/PresetUpdater.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index da61528793..cdd91eb22e 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -815,19 +815,24 @@ bool PresetUpdater::priv::get_cached_plugins_version(std::string& cached_version live555_library = cache_folder.string() + "/liblive555.so"; #endif + std::string changelog_file = cache_folder.string() + "/network_plugins.json"; if (boost::filesystem::exists(network_library) && boost::filesystem::exists(player_library) - && boost::filesystem::exists(live555_library)) + && boost::filesystem::exists(live555_library) + && boost::filesystem::exists(changelog_file)) { - std::string changelog_file = cache_folder.string() + "/network_plugins.json"; has_plugins = true; try { boost::nowide::ifstream ifs(changelog_file); json j; ifs >> j; - cached_version = j["version"]; - force = j["force"]; + if (j.contains("version")) + cached_version = j["version"]; + if (j.contains("force")) + force = j["force"]; + + BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< ": cached_version = "<