Check that region to patch/copy on "cmd" is not empty to avoid useless cmds

This commit is contained in:
David Capello 2019-04-28 21:26:12 -03:00
parent 23f00d87f6
commit b768d99743
3 changed files with 22 additions and 15 deletions

View File

@ -24,6 +24,8 @@ CopyRegion::CopyRegion(Image* dst, const Image* src,
: WithImage(dst) : WithImage(dst)
, m_alreadyCopied(alreadyCopied) , m_alreadyCopied(alreadyCopied)
{ {
ASSERT(!region.isEmpty());
// Create region to save/swap later // Create region to save/swap later
for (const auto& rc : region) { for (const auto& rc : region) {
gfx::Clip clip( gfx::Clip clip(

View File

@ -29,6 +29,7 @@ PatchCel::PatchCel(doc::Cel* dstCel,
, m_region(patchedRegion) , m_region(patchedRegion)
, m_pos(patchPos) , m_pos(patchPos)
{ {
ASSERT(!patchedRegion.isEmpty());
} }
void PatchCel::onExecute() void PatchCel::onExecute()

View File

@ -204,6 +204,9 @@ void ExpandCelCanvas::commit()
regionToPatch = &reduced; regionToPatch = &reduced;
} }
// Check that the region to copy or patch is not empty before we
// create the new cmd
if (!regionToPatch->isEmpty()) {
if (m_layer->isBackground()) { if (m_layer->isBackground()) {
m_transaction.execute( m_transaction.execute(
new cmd::CopyRegion( new cmd::CopyRegion(
@ -221,6 +224,7 @@ void ExpandCelCanvas::commit()
m_bounds.origin())); m_bounds.origin()));
} }
} }
}
else { else {
ASSERT(false); ASSERT(false);
} }