Commit 1d843a05 authored by Emmet O'Neill's avatar Emmet O'Neill
Browse files

Storyboards: Fix crash on undo of first (and only) storyboard entry.

There were some parts of the undo-redo operations that also looked
incorrect too, so in general it should be more stable.
parent 953c522a
......@@ -30,26 +30,26 @@ KisAddStoryboardCommand::~KisAddStoryboardCommand()
void KisAddStoryboardCommand::redo()
{
QModelIndex nextIndex = m_model->index(m_position, 0);
if (nextIndex.isValid()){
const int firstFrameOfScene = m_model->data(m_model->index(StoryboardItem::FrameNumber, 0, nextIndex)).toInt();
QModelIndex existingEntry = m_model->index(m_position, 0);
if (existingEntry.isValid()){
const int firstFrameOfScene = m_model->data(m_model->index(StoryboardItem::FrameNumber, 0, existingEntry)).toInt();
int durationDeletedScene = m_item->child(StoryboardItem::DurationSecond)->data().toInt() * m_model->getFramesPerSecond()
+ m_item->child(StoryboardItem::DurationFrame)->data().toInt();
m_model->shiftKeyframes(KisTimeSpan::infinite(firstFrameOfScene), durationDeletedScene);
}
KUndo2Command::redo();
m_model->insertRow(m_position);
m_model->insertChildRows(m_position, m_item);
KUndo2Command::redo();
}
void KisAddStoryboardCommand::undo()
{
updateItem();
KUndo2Command::undo();
updateItem();
QModelIndex nextIndex = m_model->index(m_position, 0);
if (nextIndex.isValid()){
const int firstFrameOfScene = m_model->data(m_model->index(StoryboardItem::FrameNumber, 0, nextIndex)).toInt();
QModelIndex nextEntry = m_model->index(m_position + 1, 0);
if (nextEntry.isValid()){
const int firstFrameOfScene = m_model->data(m_model->index(StoryboardItem::FrameNumber, 0, nextEntry)).toInt();
int durationDeletedScene = m_item->child(StoryboardItem::DurationSecond)->data().toInt() * m_model->getFramesPerSecond()
+ m_item->child(StoryboardItem::DurationFrame)->data().toInt();
m_model->shiftKeyframes(KisTimeSpan::infinite(firstFrameOfScene), -durationDeletedScene);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment