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
This commit is contained in:
YuSanka 2022-04-01 09:48:38 +02:00
parent 2ecfdea070
commit 05e94eb0ab

View File

@ -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<int>());
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"));