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

Modified Files:
      Tag: AUDACITY_1_2
        BlockFile.cpp BlockFile.h 
Log Message:
Fix potential crash on Mac caused by non-thread-safe utf8-conversion system 
call.  Now filename conversion calls are computed once and cached for filenames 
that might be accessed from the other thread.

Index: BlockFile.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/BlockFile.h,v
retrieving revision 1.11.2.3
retrieving revision 1.11.2.4
diff -u -d -r1.11.2.3 -r1.11.2.4
--- BlockFile.h 29 May 2004 04:57:50 -0000      1.11.2.3
+++ BlockFile.h 26 Feb 2007 10:17:08 -0000      1.11.2.4
@@ -129,6 +129,7 @@
 
  protected:
    wxFileName mFileName;
+   wxString mFullPath;  // cached so we don't need to recompute each time
    sampleCount mLen;
    SummaryInfo mSummaryInfo;
    float mMin, mMax, mRMS;
@@ -185,6 +186,7 @@
    virtual bool ReadSummary(void *data);
 
    wxFileName  mAliasedFileName;
+   wxString    mAliasedFullPath;
    sampleCount mAliasStart;
    int         mAliasChannel;
 };

Index: BlockFile.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/BlockFile.cpp,v
retrieving revision 1.25.2.2
retrieving revision 1.25.2.3
diff -u -d -r1.25.2.2 -r1.25.2.3
--- BlockFile.cpp       29 May 2004 04:57:50 -0000      1.25.2.2
+++ BlockFile.cpp       26 Feb 2007 10:17:08 -0000      1.25.2.3
@@ -54,12 +54,13 @@
    mLen(samples),
    mSummaryInfo(samples)
 {
+   mFullPath = FILENAME(mFileName.GetFullPath());
 }
 
 BlockFile::~BlockFile()
 {
    if (!IsLocked() && mFileName.HasName())
-      wxRemoveFile(FILENAME(mFileName.GetFullPath()));
+      wxRemoveFile(mFullPath);
 }
 
 /// Returns the file name of the disk file associated with this
@@ -468,6 +469,7 @@
    mAliasStart(aliasStart),
    mAliasChannel(aliasChannel)
 {
+   mAliasedFullPath = FILENAME(mAliasedFileName.GetFullPath());
 }
 
 AliasBlockFile::AliasBlockFile(wxFileName existingSummaryFile,
@@ -495,13 +497,13 @@
 /// summarize.
 void AliasBlockFile::WriteSummary()
 {
-   wxASSERT( !wxFileExists(FILENAME(mFileName.GetFullPath())));
+   wxASSERT(!wxFileExists(mFullPath));
    // I would much rather have this code as part of the constructor, but
    // I can't call virtual functions from the constructor.  So we just
    // need to ensure that every derived class calls this in *its* constructor
    wxFFile summaryFile;
 
-   if( !summaryFile.Open(FILENAME(mFileName.GetFullPath()), "wb") )
+   if( !summaryFile.Open(mFullPath, "wb") )
       // failed.  what to do?
       return;
 
@@ -530,7 +532,7 @@
 {
    wxFFile summaryFile;
 
-   if( !summaryFile.Open(FILENAME(mFileName.GetFullPath()), "rb") )
+   if( !summaryFile.Open(mFullPath, "rb") )
       return false;
 
    int read = summaryFile.Read(data, (size_t)mSummaryInfo.totalSummaryBytes);
@@ -557,7 +559,7 @@
 
 int AliasBlockFile::GetSpaceUsage()
 {
-   wxFFile summaryFile(FILENAME(mFileName.GetFullPath()));
+   wxFFile summaryFile(mFullPath);
    return summaryFile.Length();
 }
 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to