Commit 81658caa authored by Nicolas Carion's avatar Nicolas Carion

fix tests and regression introduced in 593e207c

parent d0046fee
......@@ -186,6 +186,9 @@ bool TimelineFunctions::requestClipCut(const std::shared_ptr<TimelineItemModel>
clipsToCut << cid;
}
}
if (clipsToCut.isEmpty()) {
return true;
}
for (int cid : clipsToCut) {
count++;
int newId;
......@@ -306,7 +309,7 @@ bool TimelineFunctions::insertZone(const std::shared_ptr<TimelineItemModel> &tim
}
result = result && TimelineFunctions::liftZone(timeline, target_track, QPoint(insertFrame, insertFrame + (zone.y() - zone.x())), undo, redo);
if (!result) {
qDebug()<<"// LIFTING ZONE FAILED\n";
qDebug() << "// LIFTING ZONE FAILED\n";
break;
}
++it;
......@@ -340,7 +343,7 @@ bool TimelineFunctions::insertZone(const std::shared_ptr<TimelineItemModel> &tim
}
}
if (!result) {
qDebug()<<"// REQUESTING SPACE FAILED";
qDebug() << "// REQUESTING SPACE FAILED";
undo();
}
return result;
......@@ -377,18 +380,19 @@ bool TimelineFunctions::liftZone(const std::shared_ptr<TimelineItemModel> &timel
bool TimelineFunctions::removeSpace(const std::shared_ptr<TimelineItemModel> &timeline, int trackId, QPoint zone, Fun &undo, Fun &redo)
{
Q_UNUSED(trackId)
std::unordered_set<int> clips;
auto it = timeline->m_allTracks.cbegin();
while (it != timeline->m_allTracks.cend()) {
int target_track = (*it)->getId();
if (timeline->m_videoTarget == target_track || timeline->m_audioTarget == target_track || timeline->getTrackById_const(target_track)->shouldReceiveTimelineOp()) {
if (timeline->m_videoTarget == target_track || timeline->m_audioTarget == target_track ||
timeline->getTrackById_const(target_track)->shouldReceiveTimelineOp()) {
std::unordered_set<int> subs = timeline->getItemsInRange(target_track, zone.y() - 1, -1, true);
clips.insert(subs.begin(), subs.end());
}
++it;
}
bool result = false;
if (!clips.empty()) {
int clipId = *clips.begin();
......@@ -426,7 +430,8 @@ bool TimelineFunctions::requestInsertSpace(const std::shared_ptr<TimelineItemMod
auto it = timeline->m_allTracks.cbegin();
while (it != timeline->m_allTracks.cend()) {
int target_track = (*it)->getId();
if (timeline->m_videoTarget == target_track || timeline->m_audioTarget == target_track || timeline->getTrackById_const(target_track)->shouldReceiveTimelineOp()) {
if (timeline->m_videoTarget == target_track || timeline->m_audioTarget == target_track ||
timeline->getTrackById_const(target_track)->shouldReceiveTimelineOp()) {
std::unordered_set<int> subs = timeline->getItemsInRange(target_track, zone.x(), -1, true);
items.insert(subs.begin(), subs.end());
}
......
......@@ -613,7 +613,11 @@ TEST_CASE("Insert/delete", "[Trimming2]")
};
state();
timeline->m_audioTarget = tid2;
timeline->m_videoTarget = tid1;
REQUIRE(TimelineFunctions::insertZone(timeline, {tid1, tid2}, binId, 3 + 2, {l / 4, 3 * l / 4}, false));
timeline->m_audioTarget = -1;
timeline->m_videoTarget = -1;
int small_length = 3 * l / 4 - l / 4;
int cid3 = timeline->getClipByPosition(tid1, 3 + 2);
int cid4 = timeline->getClipByPosition(tid2, 3 + 2);
......
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