From 4acd6ccbd54309ee0f3ccf1c57e234e9ba57108e Mon Sep 17 00:00:00 2001 From: alves Date: Wed, 22 Jul 2026 14:32:29 +0800 Subject: [PATCH 1/4] fix copy web resources decode err question. --- src/libslic3r/utils.cpp | 17 ++++++++++++++--- src/slic3r/GUI/GUI_App.cpp | 8 ++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 01aaf09f560..4af2b628ef1 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -1535,16 +1535,27 @@ bool copy_directory_recursively(const boost::filesystem::path &source, const boo std::string error_message; for (auto &dir_entry : boost::filesystem::directory_iterator(source)) { - const std::string name = dir_entry.path().filename().string(); + const boost::filesystem::path child_name = dir_entry.path().filename(); + const boost::filesystem::path dest_child = target / child_name; if (boost::filesystem::is_directory(dir_entry)) { - if (!copy_directory_recursively(dir_entry, target / name, filter)) + if (!copy_directory_recursively(dir_entry.path(), dest_child, filter)) return false; } else { +#ifdef WIN32 + const std::string name = boost::nowide::narrow(child_name.wstring()); +#else + const std::string name = child_name.string(); +#endif if (filter && filter(name)) continue; +#ifdef WIN32 + const std::string source_file = boost::nowide::narrow(dir_entry.path().wstring()); + const std::string target_file = boost::nowide::narrow(dest_child.wstring()); +#else const std::string source_file = dir_entry.path().string(); - const std::string target_file = (target / name).string(); + const std::string target_file = dest_child.string(); +#endif const CopyFileResult cfr = copy_file(source_file, target_file, error_message, false); if (cfr != CopyFileResult::SUCCESS) { BOOST_LOG_TRIVIAL(error) << "Copying failed(" << static_cast(cfr) << "): " << error_message diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index e9f4cceddfe..6c00e3afa01 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2270,7 +2270,11 @@ bool GUI_App::check_older_app_config(Semver current_version, bool backup) void GUI_App::copy_web_resources() { StartupProfiler profiler("GUI_App::copy_web_resources"); +#ifdef WIN32 + auto data_web_path = boost::filesystem::path(boost::nowide::widen(data_dir())) / "web"; +#else auto data_web_path = boost::filesystem::path(data_dir()) / "web"; +#endif if (!boost::filesystem::exists(data_web_path / "flutter_web")) { copy_bundled_flutter_web(false); profiler.mark("copy flutter_web (missing target)"); @@ -2301,7 +2305,11 @@ void GUI_App::copy_web_resources() { bool GUI_App::copy_bundled_flutter_web(bool upgrade) { auto source_path = boost::filesystem::path(resources_dir()) / "web" / "flutter_web"; +#ifdef WIN32 + auto target_path = boost::filesystem::path(boost::nowide::widen(data_dir())) / "web" / "flutter_web"; +#else auto target_path = boost::filesystem::path(data_dir()) / "web" / "flutter_web"; +#endif if (copy_directory_recursively(source_path, target_path)) return true; From cf929f9687606f0fd2035c605a6a45545b61b100 Mon Sep 17 00:00:00 2001 From: alves Date: Wed, 22 Jul 2026 14:43:32 +0800 Subject: [PATCH 2/4] fix profile path isn't utf8 question mayby copy resource incorrect. --- src/libslic3r/PresetBundle.cpp | 24 ++++++++++++++++++++++-- src/slic3r/Utils/PresetUpdater.cpp | 11 +++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index f97f468fe47..d2336180dc2 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -334,7 +334,11 @@ void PresetBundle::reset(bool delete_files) void PresetBundle::setup_directories() { +#ifdef WIN32 + boost::filesystem::path data_dir = boost::filesystem::path(boost::nowide::widen(Slic3r::data_dir())); +#else boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir()); +#endif //BBS: change directoties by design std::initializer_list paths = { data_dir, @@ -370,21 +374,31 @@ static void copy_dir(const boost::filesystem::path& from_dir, const boost::files if (!boost::filesystem::is_directory(to_dir)) boost::filesystem::create_directory(to_dir); for (auto& dir_entry : boost::filesystem::directory_iterator(from_dir)) { + const boost::filesystem::path dest_child = to_dir / dir_entry.path().filename(); if (!boost::filesystem::is_directory(dir_entry.path())) { std::string em; - CopyFileResult cfr = copy_file(dir_entry.path().string(), (to_dir / dir_entry.path().filename()).string(), em, false); +#ifdef WIN32 + CopyFileResult cfr = copy_file(boost::nowide::narrow(dir_entry.path().wstring()), + boost::nowide::narrow(dest_child.wstring()), em, false); +#else + CopyFileResult cfr = copy_file(dir_entry.path().string(), dest_child.string(), em, false); +#endif if (cfr != SUCCESS) { BOOST_LOG_TRIVIAL(error) << "Error when copying files from " << from_dir << " to " << to_dir << ": " << em; } } else { - copy_dir(dir_entry.path(), to_dir / dir_entry.path().filename()); + copy_dir(dir_entry.path(), dest_child); } } } void PresetBundle::copy_files(const std::string& from) { +#ifdef WIN32 + boost::filesystem::path data_dir = boost::filesystem::path(boost::nowide::widen(Slic3r::data_dir())); +#else boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir()); +#endif // list of searched paths based on current directory system in setup_directories() // do not copy cache and snapshots boost::filesystem::path from_data_dir = boost::filesystem::path(from); @@ -1403,9 +1417,15 @@ std::pair PresetBundle::load_system_pre // Here the vendor specific read only Config Bundles are stored. //BBS: change directory by design +#ifdef WIN32 + boost::filesystem::path dir = (boost::filesystem::path(boost::nowide::widen(data_dir())) / PRESET_SYSTEM_DIR).make_preferred(); + if (validation_mode) + dir = boost::filesystem::path(boost::nowide::widen(data_dir())).make_preferred(); +#else boost::filesystem::path dir = (boost::filesystem::path(data_dir()) / PRESET_SYSTEM_DIR).make_preferred(); if (validation_mode) dir = (boost::filesystem::path(data_dir())).make_preferred(); +#endif PresetsConfigSubstitutions substitutions; std::string errors_cummulative; diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index eb32cd9c809..17a65dc219a 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -101,7 +101,12 @@ void copy_file_fix(const fs::path &source, const fs::path &target) BOOST_LOG_TRIVIAL(debug) << format("PresetUpdater: Copying %1% -> %2%", source, target); std::string error_message; //CopyFileResult cfr = Slic3r::GUI::copy_file_gui(source.string(), target.string(), error_message, false); +#ifdef WIN32 + CopyFileResult cfr = copy_file(boost::nowide::narrow(source.wstring()), + boost::nowide::narrow(target.wstring()), error_message, false); +#else CopyFileResult cfr = copy_file(source.string(), target.string(), error_message, false); +#endif if (cfr != CopyFileResult::SUCCESS) { BOOST_LOG_TRIVIAL(error) << "Copying failed(" << cfr << "): " << error_message; throw Slic3r::CriticalException(GUI::format( @@ -317,9 +322,15 @@ struct PresetUpdater::priv //BBS: change directories by design PresetUpdater::priv::priv() +#ifdef WIN32 + : cache_path(fs::path(boost::nowide::widen(Slic3r::data_dir())) / "ota") + , rsrc_path(fs::path(resources_dir()) / "profiles") + , vendor_path(fs::path(boost::nowide::widen(Slic3r::data_dir())) / PRESET_SYSTEM_DIR) +#else : cache_path(fs::path(Slic3r::data_dir()) / "ota") , rsrc_path(fs::path(resources_dir()) / "profiles") , vendor_path(fs::path(Slic3r::data_dir()) / PRESET_SYSTEM_DIR) +#endif , cancel(false) { //BBS: refine preset updater logic From 44c4b6922596282d5a8e0a4873c0905968541867 Mon Sep 17 00:00:00 2001 From: alves Date: Thu, 23 Jul 2026 15:38:00 +0800 Subject: [PATCH 3/4] fix update resource path maybe incorrect. --- src/slic3r/Utils/PresetUpdater.cpp | 53 ++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index 17a65dc219a..6b525a2c401 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -1013,7 +1013,11 @@ void PresetUpdater::priv::sync_update_flutter_resource(bool isAuto_check) auto reservedData2 = dataObj.value("reserved_2", ""); auto localProfilesjson = cache_path / "flutter_web/version.json"; - std::string json_path = data_dir() + "/web/flutter_web/version.json"; +#ifdef WIN32 + std::string json_path = boost::nowide::narrow((boost::filesystem::path(boost::nowide::widen(data_dir())) / "web" / "flutter_web" / "version.json").wstring()); +#else + std::string json_path = (boost::filesystem::path(data_dir()) / "web" / "flutter_web" / "version.json").string(); +#endif // Use a unique filename per version to avoid deleting a zip that may still be in use (Windows file locks / concurrent UI import). std::string fileName = (cache_profile_path / ("flutter_web_" + fileVersion + ".zip")).string(); Semver currentPresetVersion = get_version_from_json(json_path); @@ -1145,7 +1149,11 @@ void PresetUpdater::priv::sync_config(bool isAuto_check) currentPresetVersion = GUI::wxGetApp().preset_bundle->get_vendor_profile_version(PresetBundle::SM_BUNDLE); else - currentPresetVersion = get_version_from_json(data_dir() + "/system/Snapmaker.json"); +#ifdef WIN32 + currentPresetVersion = get_version_from_json(boost::nowide::narrow((boost::filesystem::path(boost::nowide::widen(data_dir())) / "system" / "Snapmaker.json").wstring())); +#else + currentPresetVersion = get_version_from_json((boost::filesystem::path(data_dir()) / "system" / "Snapmaker.json").string()); +#endif std::regex matcher("[0-9]+\\.[0-9]+(\\.[0-9]+)*(-[A-Za-z0-9]+)?(\\+[A-Za-z0-9]+)?"); @@ -1243,7 +1251,11 @@ void PresetUpdater::priv::sync_tooltip(std::string http_url, std::string languag try { std::string common_version = "00.00.00.00"; std::string language_version = "00.00.00.00"; +#ifdef WIN32 + fs::path cache_root = fs::path(boost::nowide::widen(data_dir())) / "resources/tooltip"; +#else fs::path cache_root = fs::path(data_dir()) / "resources/tooltip"; +#endif try { auto vf = cache_root / "common" / "version"; if (fs::exists(vf)) Slic3r::load_string_file(vf, common_version); @@ -1271,8 +1283,11 @@ void PresetUpdater::priv::sync_tooltip(std::string http_url, std::string languag // return true means there are plugins files bool PresetUpdater::priv::get_cached_plugins_version(std::string& cached_version, bool &force) { - std::string data_dir_str = data_dir(); - boost::filesystem::path data_dir_path(data_dir_str); +#ifdef WIN32 + boost::filesystem::path data_dir_path(boost::nowide::widen(data_dir())); +#else + boost::filesystem::path data_dir_path(data_dir()); +#endif auto cache_folder = data_dir_path / "ota"; std::string network_library, player_library, live555_library; bool has_plugins = false; @@ -1357,8 +1372,11 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_ } if (need_delete_cache) { - std::string data_dir_str = data_dir(); - boost::filesystem::path data_dir_path(data_dir_str); +#if defined(_MSC_VER) || defined(_WIN32) + boost::filesystem::path data_dir_path(boost::nowide::widen(data_dir())); +#else + boost::filesystem::path data_dir_path(data_dir()); +#endif auto cache_folder = data_dir_path / "ota"; #if defined(_MSC_VER) || defined(_WIN32) @@ -1471,8 +1489,11 @@ void PresetUpdater::priv::sync_printer_config(std::string http_url) std::string using_version = curr_version.substr(0, 6) + "00.00"; std::string cached_version; - std::string data_dir_str = data_dir(); - boost::filesystem::path data_dir_path(data_dir_str); +#ifdef WIN32 + boost::filesystem::path data_dir_path(boost::nowide::widen(data_dir())); +#else + boost::filesystem::path data_dir_path(data_dir()); +#endif auto config_folder = data_dir_path / "printers"; auto cache_folder = data_dir_path / "ota" / "printers"; @@ -1660,9 +1681,13 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const Updates PresetUpdater::priv::get_printer_config_updates(bool update) const { - std::string data_dir_str = data_dir(); - boost::filesystem::path data_dir_path(data_dir_str); +#ifdef WIN32 + boost::filesystem::path data_dir_path(boost::nowide::widen(data_dir())); + boost::filesystem::path resc_dir_path(boost::nowide::widen(resources_dir())); +#else + boost::filesystem::path data_dir_path(data_dir()); boost::filesystem::path resc_dir_path(resources_dir()); +#endif auto config_folder = data_dir_path / "printers"; auto resc_folder = (update ? cache_path : resc_dir_path) / "printers"; std::string curr_version; @@ -2202,7 +2227,11 @@ void PresetUpdater::load_flutter_web(const std::string& resource_path, bool serv std::string ori_version_str = "0"; std::string ori_build_number_str = "0"; +#ifdef WIN32 + auto ori_version_file = boost::filesystem::path(boost::nowide::widen(data_dir())) / "web" / "flutter_web" / "version.json"; +#else auto ori_version_file = boost::filesystem::path(data_dir()) / "web" / "flutter_web" / "version.json"; +#endif boost::property_tree::ptree ori_config; boost::property_tree::read_json(ori_version_file.string(), ori_config); ori_version_str = ori_config.get("version", "0"); @@ -2220,7 +2249,11 @@ void PresetUpdater::load_flutter_web(const std::string& resource_path, bool serv if (current_version < online_version) { auto source_folder_path = flutter_root; +#ifdef WIN32 + auto target_folder_path = (boost::filesystem::path(boost::nowide::widen(data_dir())) / "web" / "flutter_web"); +#else auto target_folder_path = (boost::filesystem::path(data_dir()) / "web" / "flutter_web"); +#endif Version version; version.config_version = online_version; From 6595c3af2596e0fd2e8212fb2f95a25e3cf6ad47 Mon Sep 17 00:00:00 2001 From: alves Date: Fri, 24 Jul 2026 15:41:43 +0800 Subject: [PATCH 4/4] fix resource copy and no compare version info question. --- src/slic3r/GUI/GUI_App.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 6c00e3afa01..07c868248c4 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2286,10 +2286,13 @@ void GUI_App::copy_web_resources() { boost::property_tree::ptree source_config, target_config; boost::property_tree::read_json(source_version_file.string(), source_config); boost::property_tree::read_json(target_version_file.string(), target_config); - std::string source_build_number_str = source_config.get("build_number", "0"); - std::string target_build_number_str = target_config.get("build_number", "0"); + std::string source_version_str = source_config.get("version", "0"); + std::string target_version_str = target_config.get("version", "0"); - if (source_build_number_str > target_build_number_str) { + Semver source_version(source_version_str); + Semver target_version(target_version_str); + + if (target_version < source_version) { copy_bundled_flutter_web(true); profiler.mark("copy flutter_web (version upgrade)"); } else {