Commit Graph

124 Commits

Author SHA1 Message Date
Paul Licameli b6ce29d234 Bug2605: Don't leave orphans in original project after save-as 2020-12-02 13:05:22 -05:00
Paul Licameli 47bdf27f2d Revert "Bug2605: Save-as should not cause original to repoen with warnings..."
This reverts commit 742134caaa.
2020-12-02 12:39:35 -05:00
Paul Licameli 742134caaa Bug2605: Save-as should not cause original to repoen with warnings...
... Problem was that before abandoning the connection to the original path,
compaction was done only sometimes, according to the criterion of estimated
%20 space savings at least.  But this could cause the project to reopen with
orphan blocks in it, which were detected and reported as an improper save.

The easy solution is to force compaction always in this case.

Direct save does not have this problem because what would otherwise be orphaned
blocks are directly deleted from the database when undo states are destroyed
and sample blocks become unreferenced.  So compacting only sometimes does not
cause orphan blocks on reopening.
2020-12-02 00:41:07 -05:00
Paul Licameli 6944ba564c Use events to break dependency cycle introduced at 3978e8c 2020-11-25 12:24:21 -05:00
Paul Licameli 6a10177404 Bug2594: Fix Save Backup...
... It broke at 16b249a
2020-11-24 16:30:10 -05:00
Paul Licameli 7e1e339f72 Bug2599: -wal and -shm of discarded temp projects should clean up 2020-11-24 14:38:58 -05:00
Paul Licameli 0d5b9753bc Don't open a file just to query its length 2020-11-24 14:22:29 -05:00
Paul Licameli 5ebfe4670c Bug2596: Error dialogs opening unreadable project should not be blank 2020-11-24 12:43:00 -05:00
Paul Licameli e08fe884e3 Correct status message for estimated recording time onto FAT system 2020-11-23 16:08:55 -05:00
Paul Licameli a628a3efbd A function detecting when a file is hosted on a FAT system 2020-11-23 16:05:34 -05:00
Paul Licameli e3d6c37163 whitespace 2020-11-22 15:45:30 -05:00
Paul Licameli 8cb6749741 Bug2592: should clean old temp directory at exit after prefs change 2020-11-22 15:43:24 -05:00
Paul Licameli 3e0120be05 Bug2550 residual: also move -shm file if present...
... Also much other extra care in the handling of -shm and -wal files
2020-11-22 14:32:42 -05:00
Paul Licameli 98d8603931 Bug2550: Save-as must move -wal together with .aup3, if -wal exists 2020-11-21 16:39:31 -05:00
Paul Licameli caa312ab7b Remove some unneeded #includes and forward declarations 2020-11-20 13:47:47 -05:00
Paul Licameli 14c300c672 Bug2542: Discard button of auto recovery should work with UP 2020-11-19 15:18:01 -05:00
Paul Licameli a9cbd953f0 Define InvisibleTemporaryProject 2020-11-18 23:51:01 -05:00
Paul Licameli 16b249ab9f ProjectFileIO fns now take multiple pointers to const TrackLists 2020-11-18 17:30:55 -05:00
Paul Licameli 47b3b798c9 Fix comments 2020-11-18 16:57:33 -05:00
James Crook caf4eadb97 Help button for many warning messages; Restored warning icon.
The error icon was gone because we are now using the ErrorDialog, which didn't have it.  So added back explicitly.  I decided to go with wxART_WARNING rather than wxART_ERROR because nearly all of these present as warnings.
2020-09-14 17:43:28 +01:00
Paul Licameli e7b3c2b99f Cut and paste TransactionScope into DBConnection.* files 2020-09-05 14:44:34 -04:00
Paul Licameli ddc2593282 TransactionScope only requires DBConnection not ProjectFileIO 2020-09-05 14:35:24 -04:00
Paul Licameli eb7e67623e Demote error message storage from ProjectFileIO into DBConnection 2020-09-05 14:32:39 -04:00
Paul Licameli c9dec8f5a9 Factor ProjectFileIO::GetConnection (returning reference not pointer) 2020-09-05 14:30:34 -04:00
Paul Licameli cca20f4e68 Bug2533: Optimize storage of silent blocks...
... This is a more adventurous fix.  It avoids changing the schema.

Use non-positive values of SqliteSampleBlock::mBlockID to store lengths of
blocks of silence.  Keep SqliteSampleBlock structures in memory (sharing where
possible for recurring block lengths) but do not make corresponding rows in
the database table.

Reviewed all uses of mBlockID, and of SqliteSampleBlock::GetBlockID() which
returns it, and of XML attribute "blockid" which persists it.
2020-09-02 21:43:20 -04:00
Paul Licameli 92d7ee38e5
Do orphan block checking differently... (#655)
... Don't have special knowledge of "blockid" in ProjectSerializer, which should
be very low-level.

Instead, we can deserialize the project first, and use the block ids collected
by the sample block factory since f137a1e.
2020-09-01 10:54:36 -05:00
Paul Licameli c17b804750
Dont delete sample blocks prematurely (#648)
* Revert "AUP3: Don't delete sample blocks prematurely"

This reverts commit c1884349d5.

* "Don't delete sample blocks prematurely" fixed otherwise...

... and very simply.

Problem was that, only for an interactive effect (like Bass and Treble), the
save point was created, rolled back, created again, then committed.

But (unlike with the non-savepoint commands, even if savepoint is outermost),
rolling back a savepoint really just rewinds it without removing it -- therefore
the second savepoint was inner, but the first (outer) was never committed, so
some changes failed to persist.

Solution:  add a commit after rollback of savepoint to implement destructor
of AutoCommitTransaction.

The reversion of c188434 also leaves AutoCommitTransaction as a better RAII
style operation.  Rollback changes by default -- keep changes only if
success is explicitly indicated.

* Rename AutoCommitTransaction as TransactionScope...

... More appropriately, since it's now the rollback that is automatic but
the commit that must be explicit
2020-08-28 15:38:38 -05:00
Paul Licameli 1bb34e703e
Bug2529: don't lose data when closing without saving on small drive (#650) 2020-08-28 13:03:35 -05:00
Paul Licameli 29f3361746
Graceful failure saving to thumb drive... (#649)
... If renaming of the file (to a place on a different device) fails,
recover correctly before giving the warning message
2020-08-28 11:19:37 -05:00
Leland Lucius 407c83ebf0 AUP3: I think we've progressed enough to remove my abort() 2020-08-26 00:23:48 -05:00
Leland Lucius 0bbf1792fa AUP3: Don't molest project file when applying macros
Cliff reported that if you apply a macro to "Files" and you had
a "saved project" open at the time, you would get the "not saved
properly" dialog when you next open that "saved project".

This should correct it...
2020-08-26 00:06:19 -05:00
Leland Lucius 96931a8b0c AUP3: Do not use compacted file if it grows
This can happen because the new file is constructed differently
than the original and SQLite may introduce additional b-tree
pages as a result.
2020-08-02 08:03:41 -05:00
Leland Lucius 9eabb40524 AUP3: Rename project instead of copying
When saving the project and the active project is temporary,
just rename it instead of copying to reduce wait time.
2020-08-02 02:41:37 -05:00
Leland Lucius 0dca04dc3b AUP3: Fix recovery for project without autosave or project docs
Also fixes a connection restoration issue that I can't believe
didn't cause all manner of issues.
2020-08-02 01:39:19 -05:00
Leland Lucius 9f058dc308 AUP3: UP-33 History window shows misleading "space used"
I've added compact and help buttons.
2020-08-01 21:41:49 -05:00
Leland Lucius 913c41e6e8 AUP3: Minor code cleanup and addition of comments
Probably over commented for some, but I want a good refresher
a year from now when I've completely forgotten how it works.
2020-08-01 15:52:31 -05:00
Leland Lucius 8943494f8a AUP3: Better space usage calculations
Several improvements in determining how much actual disk space a
sampleblock uses. This allows us to provide how much space will
be recovered when using File -> Compact Project.

In addition, the History window now provides better space estimates.
2020-08-01 04:25:42 -05:00
Leland Lucius 6f947b39c7 Actually tried it on Linux this time...go figure!!! 2020-07-29 10:49:17 -05:00
Leland Lucius 863be98ccd AUP3: Deal with a couple of delays
The first was due to a left over bit of code in Compact and has
been removed.

The second is in SaveProject. This one can't be removed, so a
progress dialog was added.
2020-07-29 09:00:38 -05:00
Leland Lucius d4627f0daf AUP3: Reduce crash exposure when compacting
There's still the possibility if a crash happens at just the
right time that the project will be named "<project>_compact_back"
so we should probably look for it during startup.

This also changes all "Vacuum" references to "compact".
2020-07-28 23:25:50 -05:00
Leland Lucius 09f7aaad5b AUP3: UP-35 Dirty Project-2 bloat retention
Add compaction to SaveProject for the original file.
2020-07-27 23:16:27 -05:00
Leland Lucius a4554d3631 AUP3: Make sure original file gets closed
When doing a Save As, make sure autosave doc is removed
from the original project and the original project is
properly closed.  (The original project does NOT get
compacted.)
2020-07-27 19:39:26 -05:00
Leland Lucius 71ee696562 AUP3: UP-41 Opening a Saved project can get a "Project Recovered" message 2020-07-27 16:50:08 -05:00
Leland Lucius e045da472a AUP3: UP-41 Opening a Saved project can get a "Project Recovered" message 2020-07-27 16:26:11 -05:00
Leland Lucius 12f0c6ee17 AUP3: Write doc to autosave table when compacting temporary projects
This keeps them temporary if they need to be recovered.
2020-07-26 03:09:12 -05:00
Leland Lucius 6fef14dd08 AUP3: Rework Compact Project menu item and AutoRecoverDialog
Plus a couple of fixes that prevent leaving temporary files
after a project is loaded.
2020-07-26 02:01:37 -05:00
Leland Lucius c1884349d5 AUP3: Don't delete sample blocks prematurely
The wrong sample blocks would be deleted at close in step 6:

1) New Project
2) Save and name
3) Import one stereo MP3 (about 6 minutes)
4) Save, close and re-open
5) Apply Bass and Treble to the track using real-time preview
6) Save, close and re-open
7) Message Failed to retrieve sample block
2020-07-25 20:03:23 -05:00
Leland Lucius 03762d0ca3 AUP3: Fix unopened project file 2020-07-25 18:47:30 -05:00
Paul Licameli a8fd6c6ce8
Preliminaries for grouped block deletion (#628)
* Change usage of AutoCommitTransaction::Rollback...

... It is the more useful pattern (as in many finally blocks) for the failure
path in the destructor (which rolls back) to be the default, but an explicit
call must inform it of success.

This corrects the early return paths in Effect::DoEffect().

Throw inconsistency exception if Commit() is called again after having been
called once, successfully

Also remove a friend declaration

* UndoManager's interface uses consistent 0-based indexing of states...

... Returned by GetCurrentState() and used by SetStateTo(),
GetLongDescription(), GetShortDescription()

* SampleBlock::GetBlockID is const

* Generalized function to visit sample blocks used in a TrackList...

... Eliminating some duplication; put it in WaveTrack, not Track, to avoid
a dependency cycle.

* Eliminate more repetition with BlockSpaceUsageAccumulator

* Function to delete all blocks of/not-of a given set in one command
2020-07-23 11:17:29 -05:00
Paul Licameli 5bc2cb991f Do debug check for closing of DB before Project destruction safely...
... It wasn't safe, on some platforms, because the sequence of destruction
of ProjectFileIO and ConnectionPtr is unspecified.  It is safer that
ConnectionPtr just checks itself, not that ProjectFileIO fetches it again.
2020-07-23 11:06:50 -04:00