Fix issue 314 (crash): We were adding an image in the sprite's stock with a shared ImageBuffer

This commit is contained in:
David Capello 2014-02-02 23:10:09 -03:00
parent 858d7ff1b3
commit c3a03565fb

View File

@ -221,17 +221,16 @@ void ExpandCelCanvas::commit(const gfx::Rect& bounds)
} }
m_undo.pushUndoer(new undoers::ReplaceImage(m_undo.getObjects(), m_undo.pushUndoer(new undoers::ReplaceImage(m_undo.getObjects(),
m_sprite->getStock(), m_cel->getImage())); m_sprite->getStock(), m_cel->getImage()));
} }
// Replace the image in the stock. // Replace the image in the stock. We need to create a copy of
m_sprite->getStock()->replaceImage(m_cel->getImage(), m_dstImage); // image because m_dstImage's ImageBuffer cannot be shared.
m_sprite->getStock()->replaceImage(m_cel->getImage(),
Image::createCopy(m_dstImage));
// Destroy the old cel image. // Destroy the old cel image.
delete m_celImage; delete m_celImage;
// Now the m_dstImage is used, so we haven't to destroy it.
m_dstImage = NULL;
} }
m_committed = true; m_committed = true;