Fix crash trying to move the selection from a empty cel

This commit is contained in:
David Capello 2014-08-24 19:37:24 -03:00
parent d1fc7f643a
commit 0b3ec08987
3 changed files with 23 additions and 23 deletions

View File

@ -118,6 +118,7 @@ void PixelsMovement::cutMask()
{
{
ContextWriter writer(m_reader);
if (writer.cel())
m_document->getApi().clearMask(m_layer, writer.cel(),
app_get_color_to_clear_layer(m_layer));
}

View File

@ -225,17 +225,15 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
if (editor->isInsideSelection() &&
currentTool->getInk(0)->isSelection() &&
msg->left()) {
int x, y, opacity;
Image* image = location.image(&x, &y, &opacity);
if (image) {
if (!layer->isWritable()) {
Alert::show(PACKAGE "<<The layer is locked.||&Close");
return true;
}
int x, y, opacity;
Image* image = location.image(&x, &y, &opacity);
// Change to MovingPixelsState
transformSelection(editor, msg, MoveHandle);
}
return true;
}

View File

@ -52,17 +52,17 @@ Image* NewImageFromMask(const DocumentLocation& location)
ASSERT(srcSprite);
ASSERT(srcMask);
ASSERT(srcMaskBitmap);
ASSERT(src);
dst = Image::create(srcSprite->pixelFormat(), srcBounds.w, srcBounds.h);
if (!dst)
return NULL;
// Clear the new image
dst->setMaskColor(src->maskColor());
dst->setMaskColor(src ? src->maskColor(): srcSprite->transparentColor());
clear_image(dst, dst->maskColor());
// Copy the masked zones
if (src) {
const LockImageBits<BitmapTraits> maskBits(srcMaskBitmap, gfx::Rect(0, 0, srcBounds.w, srcBounds.h));
LockImageBits<BitmapTraits>::const_iterator mask_it = maskBits.begin();
@ -80,6 +80,7 @@ Image* NewImageFromMask(const DocumentLocation& location)
}
}
}
}
return dst;
}