From: Jean-Baptiste M. <nu...@kd...> - 2017-05-21 17:55:17
|
Git commit 41c725acf9b69582e074ed103f824d4d50d431f6 by Jean-Baptiste Mardelle. Committed on 21/05/2017 at 17:54. Pushed by mardelle into branch 'refactoring_timeline'. Fix composition a_track M +9 -7 src/timeline2/model/timelinemodel.cpp M +1 -1 src/timeline2/model/timelinemodel.hpp https://commits.kde.org/kdenlive/41c725acf9b69582e074ed103f824d4d50d431f6 diff --git a/src/timeline2/model/timelinemodel.cpp b/src/timeline2/model/timelinemodel.cpp index f6ee56ee3..ecbccfb6e 100644 --- a/src/timeline2/model/timelinemodel.cpp +++ b/src/timeline2/model/timelinemodel.cpp @@ -198,16 +198,18 @@ int TimelineModel::getNextTrackId(int trackId) const return (it != m_allTracks.end()) ? (*it)->getId() : -1; } -int TimelineModel::getPreviousTrackId(int trackId) const +int TimelineModel::getPreviousVideoTrackId(int trackId) const { READ_LOCK(); Q_ASSERT(isTrack(trackId)); auto it = m_iteratorTable.at(trackId); - if (it == m_allTracks.begin()) { - return -1; + while (it != m_allTracks.begin()) { + --it; + if (it != m_allTracks.begin() && (*it)->getProperty("kdenlive:audio_track").toInt() == 0) { + break; + } } - --it; - return (*it)->getId(); + return it == m_allTracks.begin() ? 0 : (*it)->getId(); } bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool updateView, Fun &undo, Fun &redo) @@ -1215,7 +1217,7 @@ bool TimelineModel::requestCompositionMove(int compoId, int trackId, int positio QWriteLocker locker(&m_lock); Q_ASSERT(isComposition(compoId)); Q_ASSERT(isTrack(trackId)); - int previousTrack = getPreviousTrackId(trackId); + int previousTrack = getPreviousVideoTrackId(trackId); if (previousTrack == -1) { // it doesn't make sense to insert a composition on the last track qDebug() << "Move failed because of last track"; @@ -1312,7 +1314,7 @@ bool TimelineModel::replantCompositions(int currentCompo) for (const auto &compo : compos) { int aTrack = m_allCompositions[compo.second]->getATrack(); Q_ASSERT(aTrack != -1); - aTrack = getTrackMltIndex(aTrack); + aTrack = aTrack == 0 ? 0 : getTrackMltIndex(aTrack); int ret = field->plant_transition(*m_allCompositions[compo.second].get(), aTrack, compo.first); qDebug() << "Planting composition " << compo.second << "in " << aTrack << "/" << compo.first << "IN = " << m_allCompositions[compo.second]->getIn() << "OUT = " << m_allCompositions[compo.second]->getOut() << "ret=" << ret; diff --git a/src/timeline2/model/timelinemodel.hpp b/src/timeline2/model/timelinemodel.hpp index 0e1c33aef..cd0be5f77 100644 --- a/src/timeline2/model/timelinemodel.hpp +++ b/src/timeline2/model/timelinemodel.hpp @@ -212,7 +212,7 @@ public: Return -1 if we give the last track @param trackId Id of the track to test */ - int getPreviousTrackId(int trackId) const; + int getPreviousVideoTrackId(int trackId) const; /* @brief Move a clip to a specific position This action is undoable |