1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-19 09:30:52 +02:00

Bug 137 (P2) - fix false positive detection of orphaned files that belong to the clipboard (triggered by cut commands)

This commit is contained in:
mchinen 2011-04-21 21:51:56 +00:00
parent cd42c0a130
commit ee9e244b77
4 changed files with 34 additions and 5 deletions

View File

@ -910,11 +910,17 @@ BlockFile *DirManager::NewODDecodeBlockFile(
return newBlockFile;
}
bool DirManager::ContainsBlockFile(BlockFile *b) {
// check what the hash returns in case the blockfile is from a different project
bool DirManager::ContainsBlockFile(BlockFile *b)
{
return b ? mBlockFileHash[b->GetFileName().GetName()] == b : NULL;
}
bool DirManager::ContainsBlockFile(wxString filepath)
{
// check what the hash returns in case the blockfile is from a different project
return mBlockFileHash[filepath] != NULL;
}
// Adds one to the reference count of the block file,
// UNLESS it is "locked", then it makes a new copy of
// the BlockFile.
@ -1695,6 +1701,8 @@ void DirManager::FindOrphanBlockFiles(
const wxArrayString& filePathArray, // input: all files in project directory
wxArrayString& orphanFilePathArray) // output: orphan files
{
DirManager *clipboardDM = NULL;
for (size_t i = 0; i < filePathArray.GetCount(); i++)
{
wxFileName fullname = filePathArray[i];
@ -1705,6 +1713,19 @@ void DirManager::FindOrphanBlockFiles(
(fullname.GetExt().IsSameAs(wxT("au")) ||
fullname.GetExt().IsSameAs(wxT("auf"))))
{
if (!clipboardDM) {
TrackList *clipTracks = AudacityProject::GetClipboardTracks();
if (clipTracks) {
TrackListIterator clipIter(clipTracks);
Track *track = clipIter.First();
if (track)
clipboardDM = track->GetDirManager();
}
}
// Ignore it if it exists in the clipboard (from a previously closed project)
if (clipboardDM && clipboardDM->ContainsBlockFile(fullname.GetFullPath()))
orphanFilePathArray.Add(fullname.GetFullPath());
}
}

View File

@ -70,8 +70,10 @@ class DirManager: public XMLTagHandler {
BlockFile *NewODDecodeBlockFile( wxString aliasedFile, sampleCount aliasStart,
sampleCount aliasLen, int aliasChannel, int decodeType);
/// Returns true if the blockfile is contained by the DirManager
/// Returns true if the blockfile pointed to by b is contained by the DirManager
bool ContainsBlockFile(BlockFile *b);
/// Check for existing using filename using complete filename
bool ContainsBlockFile(wxString filepath);
// Adds one to the reference count of the block file,
// UNLESS it is "locked", then it makes a new copy of

View File

@ -3727,6 +3727,12 @@ void AudacityProject::UpdateMixerBoard()
// Clipboard methods
//
//static
TrackList *AudacityProject::GetClipboardTracks()
{
return msClipboard;
}
//static
void AudacityProject::DeleteClipboard()
{

View File

@ -275,7 +275,7 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
void UpdateLayout();
// Other commands
static TrackList *GetClipboardTracks();
static void DeleteClipboard();
static void DeleteAllProjectsDeleteLock();