Fix crash when PixelsMovement() wants to create an extra cel without enough memory

This commit is contained in:
David Capello 2015-04-15 13:59:41 -03:00
parent 43a0279a24
commit 849e40b0f9
2 changed files with 12 additions and 8 deletions

View File

@ -278,19 +278,19 @@ void Document::prepareExtraCel(const gfx::Rect& bounds, int opacity)
{
ASSERT(sprite() != NULL);
if (!m_extraImage ||
m_extraImage->pixelFormat() != sprite()->pixelFormat() ||
m_extraImage->width() != bounds.w ||
m_extraImage->height() != bounds.h) {
Image* newImage = Image::create(sprite()->pixelFormat(), bounds.w, bounds.h);
m_extraImage.reset(newImage);
}
if (!m_extraCel)
m_extraCel = new Cel(frame_t(0), ImageRef(NULL)); // Ignored fields for this cel (frame, and image index)
m_extraCel->setPosition(bounds.getOrigin());
m_extraCel->setOpacity(opacity);
if (!m_extraImage ||
m_extraImage->pixelFormat() != sprite()->pixelFormat() ||
m_extraImage->width() != bounds.w ||
m_extraImage->height() != bounds.h) {
m_extraImage.reset(Image::create(sprite()->pixelFormat(),
bounds.w, bounds.h));
}
}
Cel* Document::getExtraCel() const

View File

@ -440,6 +440,10 @@ void StandbyState::transformSelection(Editor* editor, MouseMessage* msg, HandleT
StatusBar::instance()->showTip(1000, "The sprite is locked in other editor");
ui::set_mouse_cursor(kForbiddenCursor);
}
catch (const std::bad_alloc&) {
StatusBar::instance()->showTip(1000, "Not enough memory to transform the selection");
ui::set_mouse_cursor(kForbiddenCursor);
}
}
void StandbyState::callEyedropper(Editor* editor)