Fix crash when we press Del key to completely delete a cel

This commit is contained in:
David Capello 2016-05-04 18:58:36 -03:00
parent a2712d440d
commit eec2904974
3 changed files with 13 additions and 3 deletions

View File

@ -509,7 +509,10 @@ bool DocumentView::onClear(Context* ctx)
{
Transaction transaction(writer.context(), "Clear");
transaction.execute(new cmd::ClearMask(writer.cel()));
transaction.execute(new cmd::TrimCel(writer.cel()));
// If the cel wasn't deleted by cmd::ClearMask, we trim it.
if (writer.cel())
transaction.execute(new cmd::TrimCel(writer.cel()));
if (visibleMask &&
!Preferences::instance().selection.keepSelectionAfterClear())

View File

@ -179,7 +179,10 @@ void PixelsMovement::cutMask()
ContextWriter writer(m_reader, 1000);
if (writer.cel()) {
m_transaction.execute(new cmd::ClearMask(writer.cel()));
m_transaction.execute(new cmd::TrimCel(writer.cel()));
ASSERT(writer.cel());
if (writer.cel())
m_transaction.execute(new cmd::TrimCel(writer.cel()));
}
}

View File

@ -226,7 +226,11 @@ void cut(ContextWriter& writer)
{
Transaction transaction(writer.context(), "Cut");
transaction.execute(new cmd::ClearMask(writer.cel()));
transaction.execute(new cmd::TrimCel(writer.cel()));
ASSERT(writer.cel());
if (writer.cel())
transaction.execute(new cmd::TrimCel(writer.cel()));
transaction.execute(new cmd::DeselectMask(writer.document()));
transaction.commit();
}