mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 15:49:36 +02:00
Fix for bug 24 (unnecessary changes to the temp directory in Prefs->Directories)
This commit is contained in:
parent
811c4ffbc3
commit
8ab0148f5d
@ -126,15 +126,34 @@ void DirectoriesPrefs::OnChooseTempDir(wxCommandEvent & e)
|
|||||||
_("Choose a location to place the temporary directory"),
|
_("Choose a location to place the temporary directory"),
|
||||||
gPrefs->Read(wxT("/Directories/TempDir"),
|
gPrefs->Read(wxT("/Directories/TempDir"),
|
||||||
wxGetApp().defaultTempDir));
|
wxGetApp().defaultTempDir));
|
||||||
dlog.ShowModal();
|
int retval = dlog.ShowModal();
|
||||||
if (dlog.GetPath() != wxT("")) {
|
if (retval != wxID_CANCEL && dlog.GetPath() != wxT("")) {
|
||||||
wxFileName tmpDirPath;
|
wxFileName tmpDirPath;
|
||||||
tmpDirPath.AssignDir(dlog.GetPath());
|
tmpDirPath.AssignDir(dlog.GetPath());
|
||||||
|
|
||||||
|
// Append an "audacity_temp" directory to this path if necessary (the
|
||||||
|
// default, the existing pref (as stored in the control), and any path
|
||||||
|
// ending in a directory with the same name as what we'd add should be OK
|
||||||
|
// already)
|
||||||
|
wxString newDirName;
|
||||||
#if defined(__WXMSW__) || defined(__WXMAC__)
|
#if defined(__WXMSW__) || defined(__WXMAC__)
|
||||||
tmpDirPath.AppendDir(wxT("audacity_temp"));
|
newDirName = wxT("audacity_temp");
|
||||||
#else
|
#else
|
||||||
tmpDirPath.AppendDir(wxT(".audacity_temp"));
|
newDirName = wxT(".audacity_temp");
|
||||||
#endif
|
#endif
|
||||||
|
wxArrayString dirsInPath = tmpDirPath.GetDirs();
|
||||||
|
|
||||||
|
// If the default temp dir or user's pref dir don't end in '/' they cause
|
||||||
|
// wxFileName's == operator to construct a wxFileName representing a file
|
||||||
|
// (that doesn't exist) -- hence the constructor calls
|
||||||
|
if (tmpDirPath != wxFileName(wxGetApp().defaultTempDir, wxT("")) &&
|
||||||
|
tmpDirPath != wxFileName(mTempDir->GetValue(), wxT("")) &&
|
||||||
|
(dirsInPath.GetCount() == 0 ||
|
||||||
|
dirsInPath[dirsInPath.GetCount()-1] != newDirName))
|
||||||
|
{
|
||||||
|
tmpDirPath.AppendDir(newDirName);
|
||||||
|
}
|
||||||
|
|
||||||
mTempDir->SetValue(tmpDirPath.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR));
|
mTempDir->SetValue(tmpDirPath.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR));
|
||||||
UpdateFreeSpace(e);
|
UpdateFreeSpace(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user