Commit 83a4ab9a authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix keyframes not deleted when clip start is resized/cut.

Fixes #355
parent 4cd6df70
Pipeline #8122 passed with stage
in 21 minutes and 45 seconds
......@@ -451,7 +451,7 @@ Fun KeyframeModel::deleteKeyframe_lambda(GenTime pos, bool notify)
qDebug() << "delete lambda" << pos.frames(pCore->getCurrentFps()) << notify;
qDebug() << "before" << getAnimProperty();
Q_ASSERT(m_keyframeList.count(pos) > 0);
Q_ASSERT(pos != GenTime()); // cannot delete initial point
//Q_ASSERT(pos != GenTime()); // cannot delete initial point
int row = static_cast<int>(std::distance(m_keyframeList.begin(), m_keyframeList.find(pos)));
if (notify) beginRemoveRows(QModelIndex(), row, row);
m_keyframeList.erase(pos);
......
......@@ -391,25 +391,36 @@ void KeyframeModelList::resizeKeyframes(int oldIn, int oldOut, int in, int out,
Keyframe kf = getKeyframe(old_in, &ok);
KeyframeType type = kf.second;
getKeyframe(new_in, &ok2);
// Check keyframes after last position
if (ok && !ok2 && oldIn != 0) {
positions << old_in;
} else if (in == 0 && oldIn != 0 && ok && ok2) {
// We moved start to 0. As the 0 keyframe is always here, simply remove old position
if (!ok2) {
// Add new in point
for (const auto &param : m_parameters) {
param.second->removeKeyframe(old_in, undo, redo);
QVariant value = param.second->getInterpolatedValue(new_in);
param.second->addKeyframe(new_in, type, value, true, undo, redo);
}
}
// qDebug()<<"/// \n\nKEYS TO DELETE: "<<positions<<"\n------------------------";
if (ok && !ok2) {
if (ok) {
// Remove previous in point
for (const auto &param : m_parameters) {
QVariant value = param.second->getInterpolatedValue(new_in);
param.second->addKeyframe(new_in, type, value, true, undo, redo);
for (auto frame : positions) {
param.second->removeKeyframe(frame, undo, redo);
param.second->removeKeyframe(old_in, undo, redo);
}
}
// Remove all keyframes before in
bool nextOk = false;
kf = m_parameters.begin()->second->getNextKeyframe(GenTime(-1), &nextOk);
GenTime pos;
while (nextOk) {
pos = kf.first;
if (pos < new_in) {
for (const auto &param : m_parameters) {
param.second->removeKeyframe(pos, undo, redo);
}
kf = m_parameters.begin()->second->getNextKeyframe(pos, &nextOk);
} else {
break;
}
}
// qDebug()<<"/// \n\nKEYS TO DELETE: "<<positions<<"\n------------------------";
}
} else {
GenTime old_out(oldOut, pCore->getCurrentFps());
......
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