| 786 | } |
| 787 | |
| 788 | void ProjectFileManager::CompactProjectOnClose() |
| 789 | { |
| 790 | auto &project = mProject; |
| 791 | auto &projectFileIO = ProjectFileIO::Get(project); |
| 792 | |
| 793 | // Lock all blocks in all tracks of the last saved version, so that |
| 794 | // the sample blocks aren't deleted from the database when we destroy the |
| 795 | // sample block objects in memory. |
| 796 | if (mLastSavedTracks) |
| 797 | { |
| 798 | for (auto wt : mLastSavedTracks->Any<WaveTrack>()) |
| 799 | WaveTrackUtilities::CloseLock(*wt); |
| 800 | |
| 801 | // Attempt to compact the project |
| 802 | projectFileIO.Compact({ mLastSavedTracks.get() }); |
| 803 | |
| 804 | if ( |
| 805 | !projectFileIO.WasCompacted() && |
| 806 | UndoManager::Get(project).UnsavedChanges()) |
| 807 | { |
| 808 | // If compaction failed, we must do some work in case of close |
| 809 | // without save. Don't leave the document blob from the last |
| 810 | // push of undo history, when that undo state may get purged |
| 811 | // with deletion of some new sample blocks. |
| 812 | // REVIEW: UpdateSaved() might fail too. Do we need to test |
| 813 | // for that and report it? |
| 814 | projectFileIO.UpdateSaved(mLastSavedTracks.get()); |
| 815 | } |
| 816 | } |
| 817 | } |
| 818 | |
| 819 | bool ProjectFileManager::OpenProject() |
| 820 | { |
no test coverage detected