mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-28 16:20:50 +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)
|
: 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(
|
||||||
|
@ -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()
|
||||||
|
@ -204,21 +204,25 @@ void ExpandCelCanvas::commit()
|
|||||||
regionToPatch = &reduced;
|
regionToPatch = &reduced;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_layer->isBackground()) {
|
// Check that the region to copy or patch is not empty before we
|
||||||
m_transaction.execute(
|
// create the new cmd
|
||||||
new cmd::CopyRegion(
|
if (!regionToPatch->isEmpty()) {
|
||||||
m_cel->image(),
|
if (m_layer->isBackground()) {
|
||||||
m_dstImage.get(),
|
m_transaction.execute(
|
||||||
*regionToPatch,
|
new cmd::CopyRegion(
|
||||||
m_bounds.origin()));
|
m_cel->image(),
|
||||||
}
|
m_dstImage.get(),
|
||||||
else {
|
*regionToPatch,
|
||||||
m_transaction.execute(
|
m_bounds.origin()));
|
||||||
new cmd::PatchCel(
|
}
|
||||||
m_cel,
|
else {
|
||||||
m_dstImage.get(),
|
m_transaction.execute(
|
||||||
*regionToPatch,
|
new cmd::PatchCel(
|
||||||
m_bounds.origin()));
|
m_cel,
|
||||||
|
m_dstImage.get(),
|
||||||
|
*regionToPatch,
|
||||||
|
m_bounds.origin()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user