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

Modified Files:
        Project.cpp Project.h AudacityApp.cpp 
Log Message:
Fixes/cleans up the close of projects...at least I hope it does.  :-)

Index: Project.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Project.h,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -d -r1.107 -r1.108
--- Project.h   16 Sep 2006 05:54:36 -0000      1.107
+++ Project.h   17 Sep 2006 03:17:18 -0000      1.108
@@ -165,7 +165,6 @@
 
    bool GetIsEmpty() { return mTracks->IsEmpty(); }
    wxFileHistory *GetRecentFiles() { return mRecentFiles; }
-// audFileHistory *GetRecentProjects() { return mRecentProjects; }
 
    bool GetTracksFitVerticallyZoomed() { return mTracksFitVerticallyZoomed; } 
//lda
    void SetTracksFitVerticallyZoomed(bool flag) { mTracksFitVerticallyZoomed = 
flag; } //lda
@@ -194,7 +193,6 @@
    void OnUpdateMenus(wxUpdateUIEvent & event);
 
    void OnActivate(wxActivateEvent & event);
-   void OnPaint(wxPaintEvent & event);
    void OnMouseEvent(wxMouseEvent & event);
    void OnIconize(wxIconizeEvent &event);
    void OnSize(wxSizeEvent & event);
@@ -372,7 +370,6 @@
 
    wxTimer *mTimer;
    long mLastStatusUpdateTime;
-   long mLastUpdateUITime;
 
    wxStatusBar *mStatusBar;
 

Index: Project.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Project.cpp,v
retrieving revision 1.279
retrieving revision 1.280
diff -u -d -r1.279 -r1.280
--- Project.cpp 16 Sep 2006 05:54:35 -0000      1.279
+++ Project.cpp 17 Sep 2006 03:17:18 -0000      1.280
@@ -9,8 +9,8 @@
 *******************************************************************//**
 
 \file Project.cpp
-\brief Implements AudacityProject, AdornedRulerPanel and 
-AudacityDropTarget.  Includes Menus.cpp.
+\brief Implements AudacityProject and AudcityDropTarget.  
+Includes Menus.cpp.
 
 *//****************************************************************//**
 
@@ -30,12 +30,6 @@
 
 *//****************************************************************//**
 
-\class AdornedRulerPanel
-\brief AdornedRulerPanel provides the Audacity Ruler, including 
-the cursor for play back and record.
-
-*//****************************************************************//**
-
 \class AudacityDropTarget
 \brief AudacityDropTarget, derived from wxFileDropTarget gives 
 drag and drop functionality for audio files.
@@ -426,7 +420,6 @@
     EVT_MENU_CLOSE(AudacityProject::OnMenuEvent)
     EVT_MENU(wxID_ANY, AudacityProject::OnMenu)
     EVT_MOUSE_EVENTS(AudacityProject::OnMouseEvent)
-    EVT_PAINT(AudacityProject::OnPaint)
     EVT_CLOSE(AudacityProject::OnCloseWindow)
     EVT_SIZE(AudacityProject::OnSize)
     EVT_ACTIVATE(AudacityProject::OnActivate)
@@ -522,7 +515,6 @@
    mViewInfo.bRedrawWaveform = false;
 
    mLockPlayRegion = false;
-   mLastUpdateUITime = ::wxGetUTCTime();
 
    CreateMenusAndCommands();
 
@@ -669,7 +661,7 @@
    InitialState();
    FixScrollbars();
    mRuler->SetLeftOffset( mTrackPanel->GetLeftOffset() - 1 );  // bevel on 
AdornedRuler
-   mRuler->SetTrackPanel(mTrackPanel);
+   mRuler->SetProject(this);
 
    //
    // Set the Icon
@@ -705,87 +697,6 @@
 
 AudacityProject::~AudacityProject()
 {
-   // DMM: Save the size of the last window the user closes
-   // (unless we're quitting - then the Quit routine will
-   // do it for us).
-   if (gAudacityProjects.GetCount() == 1 &&
-       !gIsQuitting)
-      SaveWindowSize();
-
-   mIsDeleting = true;
-
-   delete mTimer;
-   mTimer=NULL;
-
-
-// JKC: For Win98 and Linux do not detach the menu bar.
-// We want wxWindows to clean it up for us.
-// TODO: Is there a Mac issue here??
-// SetMenuBar(NULL);
-
-   if (gAudioIO->IsStreamActive(mAudioIOToken)) {
-      gAudioIO->StopStream();
-
-      while(gAudioIO->IsBusy()) {
-         wxMilliSleep(100);
-      }
-   }
-
-   mTrackPanel->Destroy();
-
-   delete mImporter;
-   mImporter = NULL;
-
-   delete mTrackFactory;
-   mTrackFactory = NULL;
-
-   // Lock all blocks in all tracks of the last saved version, so that
-   // the blockfiles aren't deleted on disk when we delete the blockfiles
-   // in memory.  After it's locked, delete the data structure so that
-   // there's no memory leak.
-   if (mLastSavedTracks) {
-      TrackListIterator iter(mLastSavedTracks);
-      Track *t = iter.First();
-      while (t) {
-         if (t->GetKind() == Track::Wave)
-            ((WaveTrack *) t)->Lock();
-         t = iter.Next();
-      }
-
-      mLastSavedTracks->Clear(true);
-      delete mLastSavedTracks;
-      mLastSavedTracks = NULL;
-   }
-
-
-   delete mTags;
-   mTags = NULL;
-
-   mTracks->Clear(true);
-   delete mTracks;
-   mTracks = NULL;
-
-   delete mRecentFiles;
-   mRecentFiles = NULL;
-//   delete mRecentProjects;
-//   mRecentProjects = NULL;
-
-   // MM: Tell the DirManager it can now delete itself
-   // if it finds it is no longer needed. If it is still
-   // used (f.e. by the clipboard), it will recognize this
-   // and will destroy itself later.
-   mDirManager->Deref();
-
-#ifdef EXPERIMENTAL_VOCAL_STUDIO
-   ButtonWindow::ClearStripesAndButtons();
-#endif
-
-   // Delete the progress dialogs
-   for (mProgressCurrent = 2; mProgressCurrent >= 0; mProgressCurrent--) {
-      if (mProgressDialog[mProgressCurrent]) {
-         delete mProgressDialog[mProgressCurrent];
-      }
-   }
 }
 
 void AudacityProject::UpdateGuiPrefs()
@@ -1336,31 +1247,14 @@
 //TODO: This function is still kinda hackish, clean up
 void AudacityProject::OnUpdateMenus(wxUpdateUIEvent & event)
 {
- #if 0
-   if (::wxGetUTCTime() - mLastUpdateUITime < 3)
-      return;
-
-   mLastUpdateUITime = ::wxGetUTCTime();
- #endif
-
    UpdateMenus();
 }
 
-void AudacityProject::OnPaint(wxPaintEvent & /*event*/)
-{
-   // Unfortunately some of the code called in our destructor
-   // can trigger evens like Paint events...
-   if (mIsDeleting)
-      return;
-
-   wxPaintDC dc(this);
-}
-
 void AudacityProject::OnActivate(wxActivateEvent & event)
 {
    mActive = event.GetActive();
 
-   // LLL:  Activate events can fire during deleting, so
+   // LLL:  Activate events can fire while closing project, so
    //       protect against it.
    if (mActive && !mIsDeleting) {
       SetActiveProject(this);
@@ -1384,6 +1278,10 @@
       SetActiveProject(this);
 }
 
+// LL: All objects that have a reference to the DirManager should
+//     be deleted before the final mDirManager->Deref() in this
+//     routine.  Failing to do so can cause unwanted recursion
+//     and/or attempts to delete objects twice.
 void AudacityProject::OnCloseWindow(wxCloseEvent & event)
 {
    if (gPrefsDialogVisible) {
@@ -1398,8 +1296,8 @@
    // recording new state.
    // This code is derived from similar code in 
    // AudacityProject::~AudacityProject() and TrackPanel::OnTimer().
-   if (this->GetAudioIOToken()>0 &&
-       gAudioIO->IsStreamActive(this->GetAudioIOToken())) {
+   if (GetAudioIOToken()>0 &&
+       gAudioIO->IsStreamActive(GetAudioIOToken())) {
 
       wxBusyCursor busy;
       gAudioIO->StopStream();
@@ -1421,12 +1319,12 @@
                ((WaveTrack *)t)->Flush();
             }
          }
-         this->PushState(_("Recorded Audio"), _("Record"));
+         PushState(_("Recorded Audio"), _("Record"));
       }
 
-      this->FixScrollbars();
-      this->SetAudioIOToken(0);
-      this->RedrawProject();
+      FixScrollbars();
+      SetAudioIOToken(0);
+      RedrawProject();
    }
 
        // These two lines test for an 'empty' project.
@@ -1450,17 +1348,91 @@
                }
    }
    
+   // Stop the timer since there's no need to update anything anymore
+   delete mTimer;
+   mTimer = NULL;
+
    // The project is now either saved or the user doesn't want to save it,
    // so there's no need to keep auto save info around anymore
    DeleteCurrentAutoSaveFile();
 
-   // LL:  Moved here from destructor since the object isn't necessarily 
deleted
-   // right away (Destroy() can queue the deletion) and, during 
QuitAudacity(), a
-   // check is made for active projects.  If left in the destructor, there
-   // is a chance that the project will not have been removed from the list
-   // and it will be "closed" twice.
-   gAudacityProjects.Remove(this);
+   // DMM: Save the size of the last window the user closes
+   //
+   // LL: Save before doing anything else to the window that might make
+   //     its size change.
+   if (gAudacityProjects.GetCount() == 1) {
+      SaveWindowSize();
+   }
+
+   mIsDeleting = true;
 
+   // JKC: For Win98 and Linux do not detach the menu bar.
+   // We want wxWindows to clean it up for us.
+   // TODO: Is there a Mac issue here??
+   // SetMenuBar(NULL);
+
+   // Lock all blocks in all tracks of the last saved version, so that
+   // the blockfiles aren't deleted on disk when we delete the blockfiles
+   // in memory.  After it's locked, delete the data structure so that
+   // there's no memory leak.
+   if (mLastSavedTracks) {
+      TrackListIterator iter(mLastSavedTracks);
+      Track *t = iter.First();
+      while (t) {
+         if (t->GetKind() == Track::Wave)
+            ((WaveTrack *) t)->Lock();
+         t = iter.Next();
+      }
+
+      mLastSavedTracks->Clear(true);
+      delete mLastSavedTracks;
+      mLastSavedTracks = NULL;
+   }
+
+   // Destroy the TrackPanel early so it's not around once we start
+   // deleting things like tracks and such out from underneath it.
+   // The DestroyChildren() takes care of this for us.
+   DestroyChildren();
+   mTrackPanel = NULL;              // Make sure this gets set...see 
HandleResize()
+
+   delete mImporter;
+   mImporter = NULL;
+
+   delete mTrackFactory;
+   mTrackFactory = NULL;
+
+   delete mTags;
+   mTags = NULL;
+
+   delete mRecentFiles;
+   mRecentFiles = NULL;
+
+   // Delete all the tracks to free up memory and DirManager references.
+   mTracks->Clear(true);
+   delete mTracks;
+   mTracks = NULL;
+
+   // This must be done before the following Deref() since it holds
+   // references to the DirManager.
+   mUndoManager.ClearStates();
+
+   // MM: Tell the DirManager it can now delete itself
+   // if it finds it is no longer needed. If it is still
+   // used (f.e. by the clipboard), it will recognize this
+   // and will destroy itself later.
+   //
+   // LL: All objects with references to the DirManager should
+   //     have been deleted before this.
+   mDirManager->Deref();
+
+   // Delete the progress dialogs
+   for (mProgressCurrent = 2; mProgressCurrent >= 0; mProgressCurrent--) {
+      if (mProgressDialog[mProgressCurrent]) {
+         delete mProgressDialog[mProgressCurrent];
+      }
+   }
+
+   gAudacityProjects.Remove(this);
    if (gActiveProject == this) {
       // Find a new active project
       if (gAudacityProjects.Count() > 0) {
@@ -1493,17 +1465,6 @@
       }
    }
 
-   //BG: Process messages before we destroy the window
-   //
-   //LL: On 2006-06-18, I had a failure in Meter::OnMouse()
-   //    when quitting.  The wxSafeYield() was allowing some
-   //    messages to get processed and Meter::OnMouse() failed
-   //    when it attepted to use the result returned from
-   //    GetActiveProject().  I was unable to reproduce it and
-   //    couldn't figure out how to correct it, so the exposure
-   //    is still there.
-   //
-   wxSafeYield(NULL, true);
    Destroy();
 }
 
@@ -2747,7 +2708,6 @@
    if (::wxGetUTCTime() - mLastStatusUpdateTime < 3)
       return;
 
-
    // gAudioIO->GetNumCaptureChannels() should only be positive 
    // when we are recording.
    if (gAudioIO->GetNumCaptureChannels() > 0) {
@@ -3211,7 +3171,7 @@
          new wxProgressDialog(mProgressTitle,
                               mProgressMessage,
                               1000,
-                              this, 
+                              NULL,
                               wxPD_CAN_ABORT |
                               wxPD_ELAPSED_TIME |
                               wxPD_REMAINING_TIME |

Index: AudacityApp.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudacityApp.cpp,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -d -r1.155 -r1.156
--- AudacityApp.cpp     5 Sep 2006 21:25:25 -0000       1.155
+++ AudacityApp.cpp     17 Sep 2006 03:17:18 -0000      1.156
@@ -139,8 +139,6 @@
    // in a Save Changes dialog, don't continue.
    // BG: unless force is true
 
-   SaveWindowSize();
-
    // BG: Are there any projects open?
    if (!gAudacityProjects.IsEmpty())
    {


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to