Fix modifying slice bounds before the 1st SliceKey frame (fix #3122)

This issue brought a lot of other related issues (like slice chunks
being saved incorrectly in .aseprite file, etc.). This is an
alternative fix to PR #3141 where a std::sort() was proposed.
This commit is contained in:
David Capello 2022-02-25 09:42:32 -03:00
parent 2100c45de2
commit 2bb93247aa

View File

@ -132,7 +132,12 @@ namespace doc {
else if (it->frame() == frame)
it->setValue(std::move(value));
else {
++it;
// We must insert keys in order. So if "frame" is less than
// the "it" frame, insert() will insert the new key before the
// iterator just as we want. In other case we have to use the
// next iterator (++it).
if (frame > it->frame())
++it;
m_keys.insert(it, Key(frame, std::move(value)));
}
}