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

Fix error in composition index for 1st track.

BUG: 408081
parent 50418180
Pipeline #3997 passed with stage
in 20 minutes and 6 seconds
...@@ -174,7 +174,7 @@ int TimelineModel::getTrackIndexFromPosition(int pos) const ...@@ -174,7 +174,7 @@ int TimelineModel::getTrackIndexFromPosition(int pos) const
{ {
Q_ASSERT(pos >= 0 && pos < (int)m_allTracks.size()); Q_ASSERT(pos >= 0 && pos < (int)m_allTracks.size());
READ_LOCK(); READ_LOCK();
auto it = m_allTracks.begin(); auto it = m_allTracks.cbegin();
while (pos > 0) { while (pos > 0) {
it++; it++;
pos--; pos--;
...@@ -312,7 +312,7 @@ int TimelineModel::getTrackPosition(int trackId) const ...@@ -312,7 +312,7 @@ int TimelineModel::getTrackPosition(int trackId) const
{ {
READ_LOCK(); READ_LOCK();
Q_ASSERT(isTrack(trackId)); Q_ASSERT(isTrack(trackId));
auto it = m_allTracks.begin(); auto it = m_allTracks.cbegin();
int pos = (int)std::distance(it, (decltype(it))m_iteratorTable.at(trackId)); int pos = (int)std::distance(it, (decltype(it))m_iteratorTable.at(trackId));
return pos; return pos;
} }
...@@ -329,7 +329,7 @@ int TimelineModel::getTrackSortValue(int trackId, bool separated) const ...@@ -329,7 +329,7 @@ int TimelineModel::getTrackSortValue(int trackId, bool separated) const
if (separated) { if (separated) {
return getTrackPosition(trackId) + 1; return getTrackPosition(trackId) + 1;
} }
auto it = m_allTracks.end(); auto it = m_allTracks.cend();
int aCount = 0; int aCount = 0;
int vCount = 0; int vCount = 0;
bool isAudio = false; bool isAudio = false;
...@@ -365,7 +365,7 @@ QList<int> TimelineModel::getLowerTracksId(int trackId, TrackType type) const ...@@ -365,7 +365,7 @@ QList<int> TimelineModel::getLowerTracksId(int trackId, TrackType type) const
Q_ASSERT(isTrack(trackId)); Q_ASSERT(isTrack(trackId));
QList<int> results; QList<int> results;
auto it = m_iteratorTable.at(trackId); auto it = m_iteratorTable.at(trackId);
while (it != m_allTracks.begin()) { while (it != m_allTracks.cbegin()) {
--it; --it;
if (type == TrackType::AnyTrack) { if (type == TrackType::AnyTrack) {
results << (*it)->getId(); results << (*it)->getId();
...@@ -386,13 +386,13 @@ int TimelineModel::getPreviousVideoTrackIndex(int trackId) const ...@@ -386,13 +386,13 @@ int TimelineModel::getPreviousVideoTrackIndex(int trackId) const
READ_LOCK(); READ_LOCK();
Q_ASSERT(isTrack(trackId)); Q_ASSERT(isTrack(trackId));
auto it = m_iteratorTable.at(trackId); auto it = m_iteratorTable.at(trackId);
while (it != m_allTracks.begin()) { while (it != m_allTracks.cbegin()) {
--it; --it;
if (it != m_allTracks.begin() && !(*it)->isAudioTrack()) { if (!(*it)->isAudioTrack()) {
break; return (*it)->getId();
} }
} }
return it == m_allTracks.begin() ? 0 : (*it)->getId(); return 0;
} }
int TimelineModel::getPreviousVideoTrackPos(int trackId) const int TimelineModel::getPreviousVideoTrackPos(int trackId) const
...@@ -400,13 +400,13 @@ int TimelineModel::getPreviousVideoTrackPos(int trackId) const ...@@ -400,13 +400,13 @@ int TimelineModel::getPreviousVideoTrackPos(int trackId) const
READ_LOCK(); READ_LOCK();
Q_ASSERT(isTrack(trackId)); Q_ASSERT(isTrack(trackId));
auto it = m_iteratorTable.at(trackId); auto it = m_iteratorTable.at(trackId);
while (it != m_allTracks.begin()) { while (it != m_allTracks.cbegin()) {
--it; --it;
if (it != m_allTracks.begin() && !(*it)->isAudioTrack()) { if (!(*it)->isAudioTrack()) {
break; return getTrackMltIndex((*it)->getId());
} }
} }
return it == m_allTracks.begin() ? 0 : getTrackMltIndex((*it)->getId()); return 0;
} }
int TimelineModel::getMirrorVideoTrackId(int trackId) const int TimelineModel::getMirrorVideoTrackId(int trackId) const
...@@ -419,10 +419,10 @@ int TimelineModel::getMirrorVideoTrackId(int trackId) const ...@@ -419,10 +419,10 @@ int TimelineModel::getMirrorVideoTrackId(int trackId) const
return -1; return -1;
} }
int count = 0; int count = 0;
if (it != m_allTracks.end()) { if (it != m_allTracks.cend()) {
++it; ++it;
} }
while (it != m_allTracks.end()) { while (it != m_allTracks.cend()) {
if ((*it)->isAudioTrack()) { if ((*it)->isAudioTrack()) {
count++; count++;
} else { } else {
...@@ -433,7 +433,7 @@ int TimelineModel::getMirrorVideoTrackId(int trackId) const ...@@ -433,7 +433,7 @@ int TimelineModel::getMirrorVideoTrackId(int trackId) const
} }
++it; ++it;
} }
if (it != m_allTracks.end() && !(*it)->isAudioTrack() && count == 0) { if (it != m_allTracks.cend() && !(*it)->isAudioTrack() && count == 0) {
return (*it)->getId(); return (*it)->getId();
} }
return -1; return -1;
...@@ -457,10 +457,8 @@ int TimelineModel::getMirrorAudioTrackId(int trackId) const ...@@ -457,10 +457,8 @@ int TimelineModel::getMirrorAudioTrackId(int trackId) const
return -1; return -1;
} }
int count = 0; int count = 0;
if (it != m_allTracks.begin()) { while (it != m_allTracks.cbegin()) {
--it; --it;
}
while (it != m_allTracks.begin()) {
if (!(*it)->isAudioTrack()) { if (!(*it)->isAudioTrack()) {
count++; count++;
} else { } else {
...@@ -469,7 +467,6 @@ int TimelineModel::getMirrorAudioTrackId(int trackId) const ...@@ -469,7 +467,6 @@ int TimelineModel::getMirrorAudioTrackId(int trackId) const
} }
count--; count--;
} }
--it;
} }
if ((*it)->isAudioTrack() && count == 0) { if ((*it)->isAudioTrack() && count == 0) {
return (*it)->getId(); return (*it)->getId();
...@@ -3037,9 +3034,9 @@ const QString TimelineModel::getTrackTagById(int trackId) const ...@@ -3037,9 +3034,9 @@ const QString TimelineModel::getTrackTagById(int trackId) const
bool isAudio = getTrackById_const(trackId)->isAudioTrack(); bool isAudio = getTrackById_const(trackId)->isAudioTrack();
int count = 1; int count = 1;
int totalAudio = 2; int totalAudio = 2;
auto it = m_allTracks.begin(); auto it = m_allTracks.cbegin();
bool found = false; bool found = false;
while ((isAudio || !found) && it != m_allTracks.end()) { while ((isAudio || !found) && it != m_allTracks.cend()) {
if ((*it)->isAudioTrack()) { if ((*it)->isAudioTrack()) {
totalAudio++; totalAudio++;
if (isAudio && !found) { if (isAudio && !found) {
...@@ -3079,13 +3076,13 @@ int TimelineModel::getPreviousTrackId(int trackId) ...@@ -3079,13 +3076,13 @@ int TimelineModel::getPreviousTrackId(int trackId)
Q_ASSERT(isTrack(trackId)); Q_ASSERT(isTrack(trackId));
auto it = m_iteratorTable.at(trackId); auto it = m_iteratorTable.at(trackId);
bool audioWanted = (*it)->isAudioTrack(); bool audioWanted = (*it)->isAudioTrack();
while (it != m_allTracks.begin()) { while (it != m_allTracks.cbegin()) {
--it; --it;
if (it != m_allTracks.begin() && (*it)->isAudioTrack() == audioWanted) { if ((*it)->isAudioTrack() == audioWanted) {
break; return (*it)->getId();
} }
} }
return it == m_allTracks.begin() ? trackId : (*it)->getId(); return trackId;
} }
int TimelineModel::getNextTrackId(int trackId) int TimelineModel::getNextTrackId(int trackId)
...@@ -3094,13 +3091,13 @@ int TimelineModel::getNextTrackId(int trackId) ...@@ -3094,13 +3091,13 @@ int TimelineModel::getNextTrackId(int trackId)
Q_ASSERT(isTrack(trackId)); Q_ASSERT(isTrack(trackId));
auto it = m_iteratorTable.at(trackId); auto it = m_iteratorTable.at(trackId);
bool audioWanted = (*it)->isAudioTrack(); bool audioWanted = (*it)->isAudioTrack();
while (it != m_allTracks.end()) { while (it != m_allTracks.cend()) {
++it; ++it;
if (it != m_allTracks.end() && (*it)->isAudioTrack() == audioWanted) { if (it != m_allTracks.cend() && (*it)->isAudioTrack() == audioWanted) {
break; break;
} }
} }
return it == m_allTracks.end() ? trackId : (*it)->getId(); return it == m_allTracks.cend() ? trackId : (*it)->getId();
} }
bool TimelineModel::requestClearSelection(bool onDeletion) bool TimelineModel::requestClearSelection(bool onDeletion)
......
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