From 6bdfb13b459da9e4eaa262c27aec734c543a1958 Mon Sep 17 00:00:00 2001 From: "james.k.crook" Date: Sat, 12 Feb 2011 14:25:51 +0000 Subject: [PATCH] Fix: "\" in file name gives disk full error. Now we complain about a non-existent directory instead. (Bug 120). --- src/Project.cpp | 59 ++++++++++++++++++++++++++++++++----------------- src/Project.h | 2 ++ 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/Project.cpp b/src/Project.cpp index ede522266..473ea020f 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -2945,6 +2945,30 @@ void AudacityProject::WriteXML(XMLWriter &xmlFile) } } +// Lock all blocks in all tracks of the last saved version +void AudacityProject::LockAllBlocks() +{ + TrackListIterator iter(mLastSavedTracks); + Track *t = iter.First(); + while (t) { + if (t->GetKind() == Track::Wave) + ((WaveTrack *) t)->Lock(); + t = iter.Next(); + } +} + +// Unlock all blocks in all tracks of the last saved version +void AudacityProject::UnlockAllBlocks() +{ + TrackListIterator iter(mLastSavedTracks); + Track *t = iter.First(); + while (t) { + if (t->GetKind() == Track::Wave) + ((WaveTrack *) t)->Unlock(); + t = iter.Next(); + } +} + bool AudacityProject::Save(bool overwrite /* = true */ , bool fromSaveAs /* = false */, bool bWantSaveCompressed /*= false*/) @@ -3025,6 +3049,16 @@ bool AudacityProject::Save(bool overwrite /* = true */ , mWantSaveCompressed = bWantSaveCompressed; bool success = false; + + if( !wxDir::Exists( projPath ) ){ + wxMessageBox(wxString::Format( + _("Could not save project. Path not found. Try creating \ndirectory \"%s\" before saving project with this name."), + projPath.c_str()), + _("Error saving project"), + wxICON_ERROR, this); + return false; + } + if (bWantSaveCompressed) { //v Move this condition into SaveCompressedWaveTracks() if want to support other formats. @@ -3041,30 +3075,15 @@ bool AudacityProject::Save(bool overwrite /* = true */ , // (Otherwise the new project would be fine, but the old one would // be empty of all of its files.) - // Lock all blocks in all tracks of the last saved version - if (mLastSavedTracks && !overwrite) { - TrackListIterator iter(mLastSavedTracks); - Track *t = iter.First(); - while (t) { - if (t->GetKind() == Track::Wave) - ((WaveTrack *) t)->Lock(); - t = iter.Next(); - } - } + if (mLastSavedTracks && !overwrite) + LockAllBlocks(); + // This renames the project directory, and moves or copies // all of our block files over. success = mDirManager->SetProject(projPath, projName, !overwrite); - // Unlock all blocks in all tracks of the last saved version - if (mLastSavedTracks && !overwrite) { - TrackListIterator iter(mLastSavedTracks); - Track *t = iter.First(); - while (t) { - if (t->GetKind() == Track::Wave) - ((WaveTrack *) t)->Unlock(); - t = iter.Next(); - } - } + if (mLastSavedTracks && !overwrite) + UnlockAllBlocks(); } if (!success) { diff --git a/src/Project.h b/src/Project.h index a16650a51..6326e5013 100644 --- a/src/Project.h +++ b/src/Project.h @@ -198,6 +198,8 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame, void AddImportedTracks(wxString fileName, Track **newTracks, int numTracks); + void LockAllBlocks(); + void UnlockAllBlocks(); bool Save(bool overwrite = true, bool fromSaveAs = false, bool bWantSaveCompressed = false); bool SaveAs(bool bWantSaveCompressed = false); #ifdef USE_LIBVORBIS