Use const &values for clip/composition sorting on group move.

Might help related to #473
parent a11cc87f
Pipeline #11616 passed with stage
in 13 minutes and 46 seconds
......@@ -1407,16 +1407,16 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
}
// Sort clips first
std::vector<int> sorted_clips(all_clips.begin(), all_clips.end());
std::sort(sorted_clips.begin(), sorted_clips.end(), [this, delta_pos](const int clipId1, const int clipId2) {
std::vector<int> sorted_clips{std::make_move_iterator(std::begin(all_clips)), std::make_move_iterator(std::end(all_clips))};
std::sort(sorted_clips.begin(), sorted_clips.end(), [this, delta_pos](const int &clipId1, const int &clipId2) {
int p1 = m_allClips[clipId1]->getPosition();
int p2 = m_allClips[clipId2]->getPosition();
return delta_pos > 0 ? p2 <= p1 : p1 <= p2;
});
// Sort compositions. We need to delete in the move direction from top to bottom
std::vector<int> sorted_compositions(all_compositions.begin(), all_compositions.end());
std::sort(sorted_compositions.begin(), sorted_compositions.end(), [this, delta_track, delta_pos](const int clipId1, const int clipId2) {
std::vector<int> sorted_compositions{std::make_move_iterator(std::begin(all_compositions)), std::make_move_iterator(std::end(all_compositions))};
std::sort(sorted_compositions.begin(), sorted_compositions.end(), [this, delta_track, delta_pos](const int &clipId1, const int &clipId2) {
int p1 = delta_track < 0
? getTrackMltIndex(m_allCompositions[clipId1]->getCurrentTrackId())
: delta_track > 0 ? -getTrackMltIndex(m_allCompositions[clipId1]->getCurrentTrackId()) : m_allCompositions[clipId1]->getPosition();
......@@ -1550,7 +1550,6 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
}
delta_pos = qMin(delta_pos, newStart - (current_in + playtime));
}
}
}
}
......
......@@ -2366,8 +2366,8 @@ bool TimelineController::endFakeGroupMove(int clipId, int groupId, int delta_tra
Fun local_redo = []() { return true; };
// Sort clips. We need to delete from right to left to avoid confusing the view
std::vector<int> sorted_clips(all_items.begin(), all_items.end());
std::sort(sorted_clips.begin(), sorted_clips.end(), [this](const int clipId1, const int clipId2) {
std::vector<int> sorted_clips{std::make_move_iterator(std::begin(all_items)), std::make_move_iterator(std::end(all_items))};
std::sort(sorted_clips.begin(), sorted_clips.end(), [this](const int &clipId1, const int &clipId2) {
int p1 = m_model->isClip(clipId1) ? m_model->m_allClips[clipId1]->getPosition() : m_model->m_allCompositions[clipId1]->getPosition();
int p2 = m_model->isClip(clipId2) ? m_model->m_allClips[clipId2]->getPosition() : m_model->m_allCompositions[clipId2]->getPosition();
return p2 <= p1;
......
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