mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-25 23:37:05 +00:00
Check that region to patch/copy on "cmd" is not empty to avoid useless cmds
This commit is contained in:
parent
23f00d87f6
commit
b768d99743
@ -24,6 +24,8 @@ CopyRegion::CopyRegion(Image* dst, const Image* src,
|
||||
: WithImage(dst)
|
||||
, m_alreadyCopied(alreadyCopied)
|
||||
{
|
||||
ASSERT(!region.isEmpty());
|
||||
|
||||
// Create region to save/swap later
|
||||
for (const auto& rc : region) {
|
||||
gfx::Clip clip(
|
||||
|
@ -29,6 +29,7 @@ PatchCel::PatchCel(doc::Cel* dstCel,
|
||||
, m_region(patchedRegion)
|
||||
, m_pos(patchPos)
|
||||
{
|
||||
ASSERT(!patchedRegion.isEmpty());
|
||||
}
|
||||
|
||||
void PatchCel::onExecute()
|
||||
|
@ -204,21 +204,25 @@ void ExpandCelCanvas::commit()
|
||||
regionToPatch = &reduced;
|
||||
}
|
||||
|
||||
if (m_layer->isBackground()) {
|
||||
m_transaction.execute(
|
||||
new cmd::CopyRegion(
|
||||
m_cel->image(),
|
||||
m_dstImage.get(),
|
||||
*regionToPatch,
|
||||
m_bounds.origin()));
|
||||
}
|
||||
else {
|
||||
m_transaction.execute(
|
||||
new cmd::PatchCel(
|
||||
m_cel,
|
||||
m_dstImage.get(),
|
||||
*regionToPatch,
|
||||
m_bounds.origin()));
|
||||
// Check that the region to copy or patch is not empty before we
|
||||
// create the new cmd
|
||||
if (!regionToPatch->isEmpty()) {
|
||||
if (m_layer->isBackground()) {
|
||||
m_transaction.execute(
|
||||
new cmd::CopyRegion(
|
||||
m_cel->image(),
|
||||
m_dstImage.get(),
|
||||
*regionToPatch,
|
||||
m_bounds.origin()));
|
||||
}
|
||||
else {
|
||||
m_transaction.execute(
|
||||
new cmd::PatchCel(
|
||||
m_cel,
|
||||
m_dstImage.get(),
|
||||
*regionToPatch,
|
||||
m_bounds.origin()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user