From c3a03565fbb4f4f2b211df887815dfbc5160b6d9 Mon Sep 17 00:00:00 2001 From: David Capello Date: Sun, 2 Feb 2014 23:10:09 -0300 Subject: [PATCH] Fix issue 314 (crash): We were adding an image in the sprite's stock with a shared ImageBuffer --- src/app/util/expand_cel_canvas.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/app/util/expand_cel_canvas.cpp b/src/app/util/expand_cel_canvas.cpp index 26c10fc20..e11ab8f98 100644 --- a/src/app/util/expand_cel_canvas.cpp +++ b/src/app/util/expand_cel_canvas.cpp @@ -221,17 +221,16 @@ void ExpandCelCanvas::commit(const gfx::Rect& bounds) } 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. - m_sprite->getStock()->replaceImage(m_cel->getImage(), m_dstImage); + // Replace the image in the stock. We need to create a copy of + // 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. delete m_celImage; - - // Now the m_dstImage is used, so we haven't to destroy it. - m_dstImage = NULL; } m_committed = true;