Fix limitless clips incorrectly resized on insert in timeline if size > initial length

parent 9dad2d7c
......@@ -126,10 +126,10 @@ ClipModel::~ClipModel() {}
bool ClipModel::requestResize(int size, bool right, Fun &undo, Fun &redo, bool logUndo)
{
qDebug() << "++++++++++ PERFORMAING CLIP RESIZE====";
qDebug() << "++++++++++ PERFORMAING CLIP RESIZE==: "<<size;
QWriteLocker locker(&m_lock);
// qDebug() << "RESIZE CLIP" << m_id << "target size=" << size << "right=" << right << "endless=" << m_endlessResize << "total length" <<
// m_producer->get_length() << "current length" << getPlaytime();
//qDebug() << "RESIZE CLIP" << m_id << "target size=" << size << "right=" << right << "endless=" << m_endlessResize << "total length" <<
//m_producer->get_length() << "current length" << getPlaytime();
if (!m_endlessResize && (size <= 0 || size > m_producer->get_length())) {
return false;
}
......@@ -169,6 +169,11 @@ bool ClipModel::requestResize(int size, bool right, Fun &undo, Fun &redo, bool l
qDebug() << "Error : Moving clip failed because parent timeline is not available anymore";
Q_ASSERT(false);
}
} else {
// Ensure producer is long enough
if (m_endlessResize && outPoint > m_producer->parent().get_length()) {
m_producer->set("length", outPoint + 1);
}
}
Fun operation = [this, inPoint, outPoint, track_operation]() {
if (track_operation()) {
......
......@@ -593,7 +593,10 @@ bool TimelineModel::requestClipCreation(const QString &binClipId, int &id, Playl
int in = binClipId.section(QLatin1Char('/'), 1, 1).toInt();
int out = binClipId.section(QLatin1Char('/'), 2, 2).toInt();
int initLength = m_allClips[clipId]->getPlaytime();
bool res = requestItemResize(clipId, initLength - in, false, true, local_undo, local_redo);
bool res = true;
if (in != 0) {
res = requestItemResize(clipId, initLength - in, false, true, local_undo, local_redo);
}
res = res && requestItemResize(clipId, out - in + 1, true, true, local_undo, local_redo);
if (!res) {
bool undone = local_undo();
......
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