[nostalgia/core/studio] Fix DrawCommand not to allow appending of duplicates
This commit is contained in:
@@ -68,9 +68,15 @@ struct DrawCommand: public studio::UndoCommand {
|
||||
|
||||
constexpr bool append(std::size_t idx) noexcept {
|
||||
if (m_changes.back().value.idx != idx) {
|
||||
m_changes.emplace_back(idx, m_img->pixels[idx]);
|
||||
m_img->setPixel(idx, m_palIdx);
|
||||
return true;
|
||||
// duplicate entries are bad
|
||||
auto existing = std::find_if(m_changes.cbegin(), m_changes.cend(), [idx](const auto &c) {
|
||||
return c.idx == idx;
|
||||
});
|
||||
if (existing == m_changes.cend()) {
|
||||
m_changes.emplace_back(idx, m_img->pixels[idx]);
|
||||
m_img->setPixel(idx, m_palIdx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user