From 05e94eb0abf98719dc4df3c3c2b84fdcad8dbb9c Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 1 Apr 2022 09:48:38 +0200 Subject: [PATCH] Fixed hard crash on "Convert from/to units" when several objects are selected This crash was caused by commit https://github.com/prusa3d/PrusaSlicer/commit/38b877635 --- src/slic3r/GUI/Plater.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 74ba4f777..df631f35f 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5635,6 +5635,10 @@ void Plater::convert_unit(ConversionType conv_type) if (obj_idxs.empty() && volume_idxs.empty()) return; + // We will remove object indexes after convertion + // So, resort object indexes descending to avoid the crash after remove + std::sort(obj_idxs.begin(), obj_idxs.end(), std::greater()); + TakeSnapshot snapshot(this, conv_type == ConversionType::CONV_FROM_INCH ? _L("Convert from imperial units") : conv_type == ConversionType::CONV_TO_INCH ? _L("Revert conversion from imperial units") : conv_type == ConversionType::CONV_FROM_METER ? _L("Convert from meters") : _L("Revert conversion from meters"));