Update of /cvsroot/audacity/audacity-src/src
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv21756

Modified Files:
        Track.cpp 
Log Message:
Fix crash when dragging stereo tracks due to incorrect check for presence of 
next track to swap places with.


Index: Track.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Track.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- Track.cpp   24 Aug 2007 14:00:34 -0000      1.39
+++ Track.cpp   24 Aug 2007 19:56:19 -0000      1.40
@@ -515,24 +515,37 @@
 {
    TrackListNode *p = head;
    while (p) {
+      // this while loop iterates over all tracks looking for the passed
+      // argument, t
       if (p->t == t) {
+         // this if triggers when we find the track we were passed
          TrackListNode *first = p;
+         // if there is a previous track, and that track is linked to this one,
+         // move current track pointer back to that track. This avoids trying
+         // to move the bottom track of a linked pair.
          if (first->prev && first->prev->t->GetLinked())
             first = first->prev;
 
          TrackListNode *second;
          if (!p->next)
-            return false;
+            return false;  // exit if there is no next track
          if (p->t->GetLinked())
-            second = p->next->next;
+            {  // if next track is part of linked pair
+            if (p->next->next)
+               {  // if track after next exists
+               second = p->next->next; // use it
+               }
+            else
+               {  // there isn't anything after the linked track!
+               return false;
+               }
+            }
          else
-            second = p->next;
+            second = p->next; // Just normal next track exists, so move down 
one
 
          // Second could be NULL if we've tried to move down a track
          // and there wasn't a track below.
          wxASSERT( second );
-         if( !second )
-            return false;
 
          Swap(first, second);
          return true;


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to