Fix bug which we can get stuck on MovingCelState (fix #1315)

This commit is contained in:
David Capello 2016-11-07 17:16:40 -03:00
parent 4b6fc07b06
commit 1b2b98ec38
2 changed files with 12 additions and 4 deletions

View File

@ -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<LayerImage*>(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);

View File

@ -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");
}
}
}