Re: [Audacity-devel] Data loss (bug 147)
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
From: Matt B. <mbr...@cs...> - 2004-04-30 22:56:10
|
Joshua Haberman wrote: > FYI, Mezzo handles this situation by making every blockfile belong to > a SeqBlockContext (which is the equivalent of DirManager. If you paste > from Sequence s1 into Sequence s2, s2 passes every block it intends to > use through the method SeqBlockContext::GetSeqBlockRef(SeqBlock*). If > the block already belongs to s2's context, it just increments the > block's refcount. If not, it creates a copy of the block that *does* > belong to the context. That way, OnPaste will never need to lock or > unlock blockfiles, even if something is being pasted between projects. You still need to handle the case where a project is closed while its data is still on the clipboard. When the clipboard dereferences those SeqBlocks, files used in the saved version of the project should not be deleted (or you have dataloss), but files that are *not* used in the saved version of the project *should* be deleted (or you have a leak). [You can't have a separate SeqBlockContext for the clipboard, because this would make all copying inefficient.] You can use a locking method like Audacity currently does. Alternately, projects could keep an extra reference to data in the last saved version (Audacity already does this), and do *not* decrement that ref when you close the project (Audacity currently decrements the refcount, but then locks those files instead). In pseudocode, I mean something like this: Project::Save() { if (mLastSavedTracks) { mLastSavedTracks.Deref() delete mlastSavedTracks } mLastSavedTracks = mTracks.Duplicate() mLastSavedTracks.Ref() // ... } Project::~Project() { mTracks.Deref() delete mTracks // Do NOT deref the last saved tracks. delete mLastSavedTracks // ... } I think this would achieve the same effects as the Lock() call in our current AudacityProject::Close(), but in a slightly cleaner way. |