Update of /cvsroot/audacity/audacity-src/src/effects
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv6459/src/effects

Modified Files:
        Effect.cpp Effect.h 
Log Message:
Fix problem with adding labels to existing label tracks from Nyquist
(http://n2.nabble.com/bug-writing-labels-from-Nyquist-td4077216.html#a4080809).


Index: Effect.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Effect.cpp,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- Effect.cpp  16 Aug 2009 14:44:20 -0000      1.85
+++ Effect.cpp  12 Dec 2009 23:47:37 -0000      1.86
@@ -280,6 +280,13 @@
    }
 }
 
+void Effect::AddToOutputTracks(Track *t)
+{
+   mOutputTracks->Add(t);
+   mIMap.Add(NULL);
+   mOMap.Add(t);
+}
+
 // If bGoodResult, replace mTracks tracks with successfully processed 
mOutputTracks copies.
 // Else clear and delete mOutputTracks copies.
 void Effect::ReplaceProcessedTracks(const bool bGoodResult)
@@ -308,7 +315,10 @@
       // If tracks were removed from mOutputTracks, then there will be
       // tracks in the map that must be removed from mTracks.
       while (i < cnt && mOMap[i] != o) {
-         mTracks->Remove((Track *)mIMap[i], true);
+         Track *t = (Track *) mIMap[i];
+         if (t) {
+            mTracks->Remove(t, true);
+         }
          i++;
       }
 
@@ -318,24 +328,36 @@
       // Remove the track from the output list...don't delete it
       x = iterOut.RemoveCurrent(false);
 
-      // Replace mTracks entry with the new track...don't delete original track
       Track *t = (Track *) mIMap[i];
-      mTracks->Replace(t, o, false);
-
-      // Swap the wavecache track the ondemand task uses, since now the new
-      // one will be kept in the project
-      if (ODManager::IsInstanceCreated()) {
-         ODManager::Instance()->ReplaceWaveTrack((WaveTrack *)t, (WaveTrack 
*)o);
+      if (t == NULL)
+      {
+         // This track is a new addition to output tracks; add it to mTracks
+         mTracks->Add(o);
       }
+      else
+      {
+         // Replace mTracks entry with the new track
+         mTracks->Replace(t, o, false);
 
-      // No longer need the original track
-      delete t;
+         // Swap the wavecache track the ondemand task uses, since now the new
+         // one will be kept in the project
+         if (ODManager::IsInstanceCreated()) {
+            ODManager::Instance()->ReplaceWaveTrack((WaveTrack *)t,
+                                                    (WaveTrack *)o);
+         }
+
+         // No longer need the original track
+         delete t;
+      }
    }
 
    // If tracks were removed from mOutputTracks, then there may be tracks
    // left at the end of the map that must be removed from mTracks.
    while (i < cnt) {
-      mTracks->Remove((Track *)mIMap[i], true);
+      Track *t = (Track *) mIMap[i];
+      if (t) {
+         mTracks->Remove((Track *)mIMap[i], true);
+      }
       i++;
    }
 

Index: Effect.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Effect.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- Effect.h    16 Aug 2009 14:44:20 -0000      1.52
+++ Effect.h    12 Dec 2009 23:47:37 -0000      1.53
@@ -252,12 +252,15 @@
    // Use these two methods to copy the input tracks to mOutputTracks, if 
    // doing the processing on them, and replacing the originals only on 
success (and not cancel).
    void CopyInputTracks(int trackType = Track::Wave);
-   
+
    // If bGoodResult, replace mWaveTracks tracks in mTracks with successfully 
processed 
    // mOutputTracks copies, get rid of old mWaveTracks, and set mWaveTracks to 
mOutputTracks. 
    // Else clear and delete mOutputTracks copies.
    void ReplaceProcessedTracks(const bool bGoodResult);
 
+   // Use this to append a new output track.
+   void AddToOutputTracks(Track *t);
+
  // Used only by the base Effect class
  //
  private:


------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Audacity-cvs mailing list
Audacity-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to