From 1b2b98ec3886b746672b6afa35a2fcc22e9c6908 Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 7 Nov 2016 17:16:40 -0300 Subject: [PATCH] Fix bug which we can get stuck on MovingCelState (fix #1315) --- src/app/ui/editor/moving_cel_state.cpp | 4 ++-- src/app/ui/editor/standby_state.cpp | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/ui/editor/moving_cel_state.cpp b/src/app/ui/editor/moving_cel_state.cpp index c11bfb61d..ad77ecbf3 100644 --- a/src/app/ui/editor/moving_cel_state.cpp +++ b/src/app/ui/editor/moving_cel_state.cpp @@ -36,7 +36,7 @@ MovingCelState::MovingCelState(Editor* editor, MouseMessage* msg) : m_reader(UIContext::instance(), 500) , m_canceled(false) { - ContextWriter writer(m_reader); + ContextWriter writer(m_reader, 500); Document* document = editor->document(); auto range = App::instance()->timeline()->range(); LayerImage* layer = static_cast(editor->layer()); @@ -92,7 +92,7 @@ bool MovingCelState::onMouseUp(Editor* editor, MouseMessage* msg) // If the user didn't cancel the operation... if (!m_canceled) { - ContextWriter writer(m_reader); + ContextWriter writer(m_reader, 1000); Transaction transaction(writer.context(), "Cel Movement", ModifyDocument); DocumentApi api = document->getApi(transaction); diff --git a/src/app/ui/editor/standby_state.cpp b/src/app/ui/editor/standby_state.cpp index 39121ad24..d5b5f84ab 100644 --- a/src/app/ui/editor/standby_state.cpp +++ b/src/app/ui/editor/standby_state.cpp @@ -221,8 +221,16 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg) "Cel is empty, nothing to move"); } else { - // Change to MovingCelState - editor->setState(EditorStatePtr(new MovingCelState(editor, msg))); + try { + // Change to MovingCelState + MovingCelState* newState = new MovingCelState(editor, msg); + editor->setState(EditorStatePtr(newState)); + } + catch (const LockedDocumentException& ex) { + // TODO break the background task that is locking this sprite + StatusBar::instance()->showTip(1000, + "Sprite is used by a backup/data recovery task"); + } } }