From 0d25141a9026cee9be526f569ebb1f0efed37423 Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Fri, 23 Sep 2022 12:00:05 +0800 Subject: [PATCH] FIX: prompt when cancel loading 3mf Change-Id: Id4a472a4d4ece3202fd8374e2154533c44e41635 (cherry picked from commit 3953223bb46dac8a39a54859b5e7579e8c6c318e) --- src/slic3r/GUI/Plater.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 24f1405a3..a1061f69d 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2595,6 +2595,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ { std::vector empty_result; bool dlg_cont = true; + bool is_user_cancel = false; if (input_files.empty()) { return std::vector(); } @@ -2707,7 +2708,8 @@ std::vector Plater::priv::load_files(const std::vector& input_ // BBS: backup & restore model = Slic3r::Model::read_from_archive(path.string(), &config_loaded, &config_substitutions, en_3mf_file_type, strategy, &plate_data, &project_presets, &file_version, - [this, &dlg, real_filename, &progress_percent, &file_percent, stage_percent, INPUT_FILES_RATIO, total_files, i](int import_stage, int current, int total, bool &cancel) { + [this, &dlg, real_filename, &progress_percent, &file_percent, stage_percent, INPUT_FILES_RATIO, total_files, i, + &is_user_cancel](int import_stage, int current, int total, bool &cancel) { bool cont = true; float percent_float = (100.0f * (float)i / (float)total_files) + INPUT_FILES_RATIO * ((float)stage_percent[import_stage] + (float)current * (float)(stage_percent[import_stage + 1] - stage_percent[import_stage]) /(float) total) / (float)total_files; BOOST_LOG_TRIVIAL(trace) << "load_3mf_file: percent(float)=" << percent_float << ", stage = " << import_stage << ", curr = " << current << ", total = " << total; @@ -2715,6 +2717,8 @@ std::vector Plater::priv::load_files(const std::vector& input_ wxString msg = wxString::Format(_L("Loading file: %s"), from_path(real_filename)); cont = dlg.Update(progress_percent, msg); cancel = !cont; + if (cancel) + is_user_cancel = cancel; }); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format(", plate_data.size %1%, project_preset.size %2%, is_bbs_3mf %3%, file_version %4% \n") % plate_data.size() % @@ -3032,7 +3036,8 @@ std::vector Plater::priv::load_files(const std::vector& input_ GUI::show_error(q, message); continue; } catch (const std::exception &e) { - GUI::show_error(q, e.what()); + if (!is_user_cancel) + GUI::show_error(q, e.what()); continue; } @@ -3265,8 +3270,10 @@ std::vector Plater::priv::load_files(const std::vector& input_ if (tolal_model_count <= 0 && !q->m_exported_file) { dlg.Hide(); - MessageDialog msg(wxGetApp().mainframe, _L("The file does not contain any geometry data."), _L("Warning"), wxYES | wxICON_WARNING); - if (msg.ShowModal() == wxID_YES) {} + if (!is_user_cancel) { + MessageDialog msg(wxGetApp().mainframe, _L("The file does not contain any geometry data."), _L("Warning"), wxYES | wxICON_WARNING); + if (msg.ShowModal() == wxID_YES) {} + } } return obj_idxs; }