[vlmc-devel] commit: Fix a bad behaviour when loading a project (fixes #33). ( Ludovic Fauvet )

git at videolan.org git at videolan.org
Tue Mar 30 03:06:18 CEST 2010


vlmc | branch: master | Ludovic Fauvet <etix at l0cal.com> | Tue Mar 30 03:09:59 2010 +0200| [0be66b4c9568d89ee7973378e87d941dbc86a98c] | committer: Ludovic Fauvet 

Fix a bad behaviour when loading a project (fixes #33).

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=0be66b4c9568d89ee7973378e87d941dbc86a98c
---

 src/Gui/timeline/TracksView.cpp |   41 ++++++++++++++++----------------------
 1 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index da386be..a241105 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -121,7 +121,6 @@ TracksView::addVideoTrack()
     m_scene->invalidate(); // Redraw the background
     m_numVideoTrack++;
     emit videoTrackAdded( track );
-    updateDuration();
 }
 
 void
@@ -135,7 +134,6 @@ TracksView::addAudioTrack()
     m_scene->invalidate(); // Redraw the background
     m_numAudioTrack++;
     emit audioTrackAdded( track );
-    updateDuration();
 }
 
 void
@@ -224,41 +222,36 @@ TracksView::addMediaItem( Clip *clip, unsigned int track, MainWorkflow::TrackTyp
 {
     Q_ASSERT( clip );
 
+    // Is the clip already existing in the timeline ?
+    QList<QGraphicsItem*> trackItems = getTrack( trackType, track )->childItems();
+    for ( int i = 0; i < trackItems.size(); ++i )
+    {
+        AbstractGraphicsMediaItem *item =
+                dynamic_cast<AbstractGraphicsMediaItem*>( trackItems.at( i ) );
+        if ( !item || item->uuid() != clip->uuid() ) continue;
+        // Item already exists in the timeline, exit now.
+        return;
+    }
+
     // If there is not enough tracks to insert
     // the clip do it now.
     if ( trackType == MainWorkflow::VideoTrack )
     {
-        if ( track >= m_numVideoTrack )
+        if ( track + 1 >= m_numVideoTrack )
         {
-            unsigned int nbTrackToAdd = track - m_numVideoTrack + 1;
-            for ( unsigned int i = 0; i < nbTrackToAdd; ++i )
+            int nbTrackToAdd = ( track + 2 ) - m_numVideoTrack;
+            for ( int i = 0; i < nbTrackToAdd; ++i )
                 addVideoTrack();
         }
-        // Add the empty upper track
-        if ( track + 1 == m_numVideoTrack )
-            addVideoTrack();
     }
     else if ( trackType == MainWorkflow::AudioTrack )
     {
-        if ( track >= m_numAudioTrack )
+        if ( track + 1 >= m_numAudioTrack )
         {
-            unsigned int nbTrackToAdd = track - m_numAudioTrack + 1;
-            for ( unsigned int i = 0; i < nbTrackToAdd; ++i )
+            int nbTrackToAdd = ( track + 2 ) - m_numAudioTrack;
+            for ( int i = 0; i < nbTrackToAdd; ++i )
                 addAudioTrack();
         }
-        // Add the empty upper track
-        if ( track + 1 == m_numAudioTrack )
-            addAudioTrack();
-    }
-    // Is the clip already existing in the timeline ?
-    QList<QGraphicsItem*> trackItems = getTrack( trackType, track )->childItems();;
-    for ( int i = 0; i < trackItems.size(); ++i )
-    {
-        AbstractGraphicsMediaItem *item =
-                dynamic_cast<AbstractGraphicsMediaItem*>( trackItems.at( i ) );
-        if ( !item || item->uuid() != clip->uuid() ) continue;
-        // Item already exist: goodbye!
-        return;
     }
 
     AbstractGraphicsMediaItem *item = 0;



More information about the Vlmc-devel mailing list