From 9e561a38873a1c2f5d04a632a896149edd057bc3 Mon Sep 17 00:00:00 2001 From: "tao.jin" Date: Mon, 7 Nov 2022 14:42:30 +0800 Subject: [PATCH] FIX: cancel remove if log file is opened by other program Change-Id: I725b03a82af292f9dc81d5f5500773600346c218 (cherry picked from commit f72f4044c2d8a010d1129b4eba1220c20bdf050b) (cherry picked from commit 3a4daa90b526e8970913311fe9bd314b865c92dd) --- src/slic3r/GUI/GUI_App.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index d93eda10c..a89d4188e 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1155,7 +1155,12 @@ void GUI_App::post_init() while (files_vec.size() > LOG_FILES_MAX_NUM) { auto full_path = log_folder / boost::filesystem::path(files_vec[files_vec.size() - 1].second); BOOST_LOG_TRIVIAL(info) << "delete log file over " << LOG_FILES_MAX_NUM << ", filename: "<< files_vec[files_vec.size() - 1].second; - boost::filesystem::remove(full_path); + try { + boost::filesystem::remove(full_path); + } + catch (const std::exception& ex) { + BOOST_LOG_TRIVIAL(error) << "failed to delete log file: "<< files_vec[files_vec.size() - 1].second << ". Error: " << ex.what(); + } files_vec.pop_back(); } }