Found some major memory leaks and fixed those, but they shouldn't have caused the crashes.
No reason to DeleteContents on a RegionList immediately after it's declared (especially when not doing so when finished with the RegionList), so I removed those.
Corrected some comments. Improved readability.
Make DirManager::MoveToNewProjectDirectory(), DirManager::CopyToNewProjectDirectory(), and several BuildFromXML() methods check the result of AssignFile() and do something appropriate about it on failure, rather than ignoring it. Also made AssignFile() check whether the assigned name is well-formed, so it doesn't always return TRUE when disckcheck is FALSE.
Briefer and more correct checks for uninitialized wxFileName objects.
Several "//ANSWER-ME" comments about file ops and commented-out cruft to probably remove.
Clarify some logic and readability.
Only TrackPanel::SelectionHandleClick() and TrackPanel::SelectionHandleDrag() called ExtendSelection(). I made ExtendSelection() not call ModifyState() and moved it into SelectionHandleClick.
When dragging completes, the (event.LeftUp() || event.RightUp()) clause in TrackPanel::HandleSelect() calls AudacityProject::ModifyState().
Fixed bug Martyn noticed, where clicking on the sync-lock icon caused the track to (un)minimize. This was because TrackInfo::GetMinimizeRect() was still returning the full size, which I had just adjusted in TrackInfo::DrawMinimize(), so the capture test in other places was wrong. Moved the size adjustment into TrackInfo::GetMinimizeRect().
Also got rid of unused bool minimized parameters of TrackInfo::GetMinimizeRect() and TrackInfo::DrawMinimize(). It wasn't used at all in TrackInfo::GetMinimizeRect(), so I replaced it with bIsSyncLockSelected, so it can determine whether to reduce the width to give room for the sync-lock icon. For TrackInfo::DrawMinimize(), it was unnecessary, because the track was also getting passed in, so no need to call t->GetMinimized() in every call to DrawMinimize() -- just call it within DrawMinimize().
Remove tiles from rulers. They were interfering with visibility of ruler marks.
Restore the icon to TrackInfo, but not in the title bar. Instead, when sync-lock is on and the track IsSyncLockSelected(), decrease the width of the minimize button and show the icon to the right of it. This way, it shows even when the track is minimized.
In light of discussion about crazy things users do, decided to leave in the former "Temporarily replace..." options, but changed the wording to "Treat missing audio as silence" and warn that the waveform may not show silence.
Added FSCKstatus_SAVE_AUP flag (and returned FSCKstatus_* to being flags). FSCKstatus_SAVE_AUP is set for missing aliased files, so that AudacityProject does a save, fixing a bug where after "Close project immediately...", opening other projects failed in a way that made them incorrectly report missing _data folders, rather than go through Project Check (DirManager::ProjectFSCK).
Decided to continue with the fake-out fixes for missing aliased files and missing SimpleBlockFiles, i.e., writing zeroes instead of replacing with SilentBlockFiles. Replacing is difficult, and there are other places where the zeroes trick is used, e.g., after project check, if there's a disk error, such as a .au being inaccessible in the middle of edits.
Made the "permanent immediately" and "regenerate" options not do a PushState, because they were not possible to Undo.
DirManager::ProjectFSCK (project check):
Made the enumerations interleaved with handling, because,
for example, user choosing to replace missing aliased block files with silence
needs to put in SilentBlockFiles and delete the corresponding auf files,
so those would then not be cumulated in missingAliasBlockFileHash.
We still do the FindX methods outside the conditionals,
so the log always shows all found errors.
Moved check for orphan files to last, so user first has a chance to get
messages about missing files that user may have mistakenly renamed
(and the renamed ones would appear to be orphans).
Re-ordered user choices for orphan files dialog to safest-to-boldest.
Changed FSCKstatus_CLOSEREQ and FSCKstatus_CHANGED to be integers rather
than binary flags. They were never returned with both in the result, nor used that way.
Made the project check log warnings use full paths instead of just file names.
Removed close box and system menu from MultiDialog, so that project check dialogs cannot just be closed. User has to decide on one of the choices.
Fixed some handling in AudacityProject::OnShowLog(). If the log was already showing before MultiDialog came up, it froze because it was not re-enabled.
Returned some of them to wxLogMessage from wxLogDebug.
Made paths displayed consistently with '%s'. Changed some wordings for grammar and clarity.
Var renames for clarity. Moved some declarations closer to their usage.
Commented out the places where sys error logging was suppressed. There was no explanation why they were suppressed.
More comments about things to fix (FIX-ME items this time).
Made AudacityProject::OnShowLog make the log window taller so more likely to show the bottom. The implementation of wxLogWindow makes it hard/impossible to scroll to the bottom.
Fix error of duplicate reports of missing aliased files.
restructuring and renaming for clarity, granularity, and reduction of code duplication
Found and commented on more errors in this code. In the "Close immediately" cases, it doesn't do a real close and that can break subsequent opening of other or the same problematic projects.
Changed several cases where GetDirManager()->ProjectFSCK returned FSCKstatus_CHANGED. These caused a PushState, but Undo could not do anything. Changed corresponding wordings for "Replace missing audio with silence" to say "permanent immediately" instead of "permanent on save", which was incorrect.