diff --git a/src/app/document.cpp b/src/app/document.cpp index a4e06b82c..5a2741336 100644 --- a/src/app/document.cpp +++ b/src/app/document.cpp @@ -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 diff --git a/src/app/ui/editor/standby_state.cpp b/src/app/ui/editor/standby_state.cpp index 85d6d68bd..a3ef4d1f4 100644 --- a/src/app/ui/editor/standby_state.cpp +++ b/src/app/ui/editor/standby_state.cpp @@ -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)