mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-02 13:20:12 +00:00
Patch a possible crash when dropping pixels onBeforeFrameChanged
This is not a "real fix". But we hope the program at least doesn't crash in this scenario. Reviewed this problem on #275, #424, and #690
This commit is contained in:
parent
ecb4c8b464
commit
61c745ee7c
@ -17,6 +17,7 @@
|
|||||||
#include "app/commands/cmd_move_mask.h"
|
#include "app/commands/cmd_move_mask.h"
|
||||||
#include "app/commands/command.h"
|
#include "app/commands/command.h"
|
||||||
#include "app/commands/commands.h"
|
#include "app/commands/commands.h"
|
||||||
|
#include "app/console.h"
|
||||||
#include "app/pref/preferences.h"
|
#include "app/pref/preferences.h"
|
||||||
#include "app/tools/ink.h"
|
#include "app/tools/ink.h"
|
||||||
#include "app/tools/tool.h"
|
#include "app/tools/tool.h"
|
||||||
@ -130,8 +131,23 @@ EditorState::LeaveAction MovingPixelsState::onLeaveState(Editor* editor, EditorS
|
|||||||
// Drop pixels if we are changing to a non-temporary state (a
|
// Drop pixels if we are changing to a non-temporary state (a
|
||||||
// temporary state is something like ScrollingState).
|
// temporary state is something like ScrollingState).
|
||||||
if (!newState || !newState->isTemporalState()) {
|
if (!newState || !newState->isTemporalState()) {
|
||||||
if (!m_discarded)
|
if (!m_discarded) {
|
||||||
|
try {
|
||||||
m_pixelsMovement->dropImage();
|
m_pixelsMovement->dropImage();
|
||||||
|
}
|
||||||
|
catch (const LockedDocumentException& ex) {
|
||||||
|
// This is one of the worst possible scenarios. We want to
|
||||||
|
// drop pixels because we're leaving this state (e.g. the user
|
||||||
|
// changed the current frame/layer, so we came from
|
||||||
|
// onBeforeFrameChanged) and we weren't able to drop those
|
||||||
|
// pixels.
|
||||||
|
//
|
||||||
|
// TODO this problem should be caught before we reach this
|
||||||
|
// state, or this problem should cancel the frame/layer
|
||||||
|
// change.
|
||||||
|
Console::showException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
editor->document()->resetTransformation();
|
editor->document()->resetTransformation();
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ void PixelsMovement::flipImage(doc::algorithm::FlipType flipType)
|
|||||||
flipType);
|
flipType);
|
||||||
|
|
||||||
{
|
{
|
||||||
ContextWriter writer(m_reader, 500);
|
ContextWriter writer(m_reader, 5000);
|
||||||
|
|
||||||
// Regenerate the transformed (rotated, scaled, etc.) image and
|
// Regenerate the transformed (rotated, scaled, etc.) image and
|
||||||
// mask.
|
// mask.
|
||||||
@ -119,7 +119,7 @@ void PixelsMovement::flipImage(doc::algorithm::FlipType flipType)
|
|||||||
void PixelsMovement::cutMask()
|
void PixelsMovement::cutMask()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
ContextWriter writer(m_reader, 500);
|
ContextWriter writer(m_reader, 5000);
|
||||||
if (writer.cel())
|
if (writer.cel())
|
||||||
m_transaction.execute(new cmd::ClearMask(writer.cel()));
|
m_transaction.execute(new cmd::ClearMask(writer.cel()));
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ void PixelsMovement::copyMask()
|
|||||||
// m_transaction.setMaskPosition)
|
// m_transaction.setMaskPosition)
|
||||||
Mask emptyMask;
|
Mask emptyMask;
|
||||||
{
|
{
|
||||||
ContextWriter writer(m_reader, 500);
|
ContextWriter writer(m_reader, 5000);
|
||||||
m_document->generateMaskBoundaries(&emptyMask);
|
m_document->generateMaskBoundaries(&emptyMask);
|
||||||
update_screen_for_document(m_document);
|
update_screen_for_document(m_document);
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ void PixelsMovement::catchImageAgain(const gfx::Point& pos, HandleType handle)
|
|||||||
// m_transaction.setMaskPosition)
|
// m_transaction.setMaskPosition)
|
||||||
Mask emptyMask;
|
Mask emptyMask;
|
||||||
{
|
{
|
||||||
ContextWriter writer(m_reader, 500);
|
ContextWriter writer(m_reader, 5000);
|
||||||
m_document->generateMaskBoundaries(&emptyMask);
|
m_document->generateMaskBoundaries(&emptyMask);
|
||||||
update_screen_for_document(m_document);
|
update_screen_for_document(m_document);
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ void PixelsMovement::moveImage(const gfx::Point& pos, MoveModifier moveModifier)
|
|||||||
gfx::Transformation::Corners oldCorners;
|
gfx::Transformation::Corners oldCorners;
|
||||||
m_currentData.transformBox(oldCorners);
|
m_currentData.transformBox(oldCorners);
|
||||||
|
|
||||||
ContextWriter writer(m_reader, 500);
|
ContextWriter writer(m_reader, 5000);
|
||||||
int x1, y1, x2, y2;
|
int x1, y1, x2, y2;
|
||||||
|
|
||||||
x1 = m_initialData.bounds().x;
|
x1 = m_initialData.bounds().x;
|
||||||
@ -444,7 +444,7 @@ void PixelsMovement::stampImage()
|
|||||||
ASSERT(cel && image);
|
ASSERT(cel && image);
|
||||||
|
|
||||||
{
|
{
|
||||||
ContextWriter writer(m_reader, 500);
|
ContextWriter writer(m_reader, 5000);
|
||||||
{
|
{
|
||||||
// Expand the canvas to paste the image in the fully visible
|
// Expand the canvas to paste the image in the fully visible
|
||||||
// portion of sprite.
|
// portion of sprite.
|
||||||
@ -474,7 +474,7 @@ void PixelsMovement::dropImageTemporarily()
|
|||||||
m_isDragging = false;
|
m_isDragging = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
ContextWriter writer(m_reader, 500);
|
ContextWriter writer(m_reader, 5000);
|
||||||
|
|
||||||
// TODO Add undo information so the user can undo each transformation step.
|
// TODO Add undo information so the user can undo each transformation step.
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ void PixelsMovement::dropImage()
|
|||||||
|
|
||||||
// Destroy the extra cel (this cel will be used by the drawing
|
// Destroy the extra cel (this cel will be used by the drawing
|
||||||
// cursor surely).
|
// cursor surely).
|
||||||
ContextWriter writer(m_reader, 500);
|
ContextWriter writer(m_reader, 5000);
|
||||||
m_document->destroyExtraCel();
|
m_document->destroyExtraCel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,7 +539,7 @@ void PixelsMovement::discardImage(bool commit)
|
|||||||
|
|
||||||
// Destroy the extra cel and regenerate the mask boundaries (we've
|
// Destroy the extra cel and regenerate the mask boundaries (we've
|
||||||
// just deselect the mask).
|
// just deselect the mask).
|
||||||
ContextWriter writer(m_reader, 500);
|
ContextWriter writer(m_reader, 5000);
|
||||||
m_document->destroyExtraCel();
|
m_document->destroyExtraCel();
|
||||||
m_document->generateMaskBoundaries();
|
m_document->generateMaskBoundaries();
|
||||||
}
|
}
|
||||||
@ -567,7 +567,7 @@ gfx::Size PixelsMovement::getInitialImageSize() const
|
|||||||
|
|
||||||
void PixelsMovement::setMaskColor(color_t mask_color)
|
void PixelsMovement::setMaskColor(color_t mask_color)
|
||||||
{
|
{
|
||||||
ContextWriter writer(m_reader, 500);
|
ContextWriter writer(m_reader, 5000);
|
||||||
|
|
||||||
m_maskColor = mask_color;
|
m_maskColor = mask_color;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user