Commit Graph

91 Commits

Author SHA1 Message Date
Paul Licameli 4209c8150a Bug2764: Open Project... in Scriptables shouldn't corrupt project...
... Now new project windows are opened when .aup3 files are opened; but
behavior chages only in that case.

Wherever opening of other files invoked import code, we still do or do
not make a new project in exactly the same cases as before; such as, when
opening multiple files with File > Open, be sure each imported file still opens
in its own separate window.

This means the decision whether to open a new project must be lowered into
ProjectFileManager, where the type of the file is discovered, and we pass it a
function object so it avoids a dependency cycle with ProjectManager.

It also means the checking for errors and closing of new projects in case of
failure must be replicated at all places where ProjectFileManager::OpenProject
is called directly.

The class ProjectManager::ProjectChooser simplifies this.

Recently introduced calls to SafeToOpenProjectInto(), before
ProjectManager::OpenProject(), are now lowered into that class, delaying the
safety check so it might also be called where ProjectFileManager is used
directly.
2021-05-24 20:04:58 -04:00
Paul Licameli a1650771b1 New argument for ProjectManager::OpenProject, not yet implemented...
... It is false in exactly the cases where there is now also a check first for
the safety of opening a project file.

Those are the cases where a new project was made for imports, but this was not
necessary for safety.  Yet old behavior will be preserved in such cases.
2021-05-24 20:04:58 -04:00
Paul Licameli 97cf411dd5 Function for repeated check whether it is safe to overwrite project 2021-05-24 20:04:58 -04:00
Paul Licameli 1bed51ac80 ProjectFileManager::OpenFile returns a pointer to project 2021-05-24 20:04:57 -04:00
Paul Licameli c96d5f12bc Comments; range-for; fix unchecked dereferences of pointer-to-pointer 2021-05-24 20:04:57 -04:00
Paul Licameli f1de843246 Use Settings for default sample rate and format...
... The first is an example of a Setting with a computed default value.

Also making a new file to hold them, separate from the GUI that changes them
in QualityPrefs; fewer things depend on QualityPrefs
2021-05-17 08:46:08 -04:00
Paul Licameli 8c04ed3990 Settings objects used in AudioIOBase...
... Giving many examples of use of Settings objects.  Many other rewrites like
this should be made to eliminate as many direct uses of gPrefs as we can.

Don't rely on long distance coincidences of literals for paths or defaults.

For each of several paths like /AudioIO/Host, all uses of that path are replaced
with use of a global Settings object defined in one place, in AudioIOBase.  The
object also gives the benefit of caching the last-read or written value.

Other users of those preferences must then include "AudioIOBase.h" to make the
dependency explicit at compile time.

It should be checked that no other mentions of those paths remain in the source,
and that there was no unintended change in default values.

This also inverts dependency of AudioIOBase on RecordingPrefs, which is GUI for
changing some of these settings.
2021-05-17 08:46:08 -04:00
Paul Licameli 38e0a982ce Bug2772: Crash after failed open of corrupt project 2021-05-01 12:46:27 -04:00
Paul Licameli e653b4aaf8 Eliminate Experimental.h, configure compile options instead...
... This makes it impossible to forget to include the EXPERIMENTAL definitions
(such as when cutting and pasting code) and so get unintended quiet changes of
behavior.

The EXPERIMENTAL flags are now specified instead in new file Experimental.cmake
2021-04-27 12:40:07 -04:00
Paul Licameli b45882e8a0 Move some conditionally compiled declarations out of Experimental.h 2021-04-27 12:40:06 -04:00
James Crook 5092414757 Error reporting for open new project. 2021-04-06 18:09:28 +01:00
Paul Licameli aa0b33dc8f Detect failure to reconnect to temp project when first saving it 2020-12-06 23:20:44 -05:00
Paul Licameli 9e41e8fa7d Delay closing of databse at close some more...
... So that you don't get an error message, when you close a project without
saving changes, with the mixer board open
2020-09-17 22:26:25 -04:00
Paul Licameli 1d8cbf2798 Now cure the error dialogs alluded to in past commit 2020-09-14 15:16:54 -04:00
Paul Licameli a2e22dc17b TransactionScope for performance also when abandoning redo states 2020-09-06 17:05:33 -04:00
Paul Licameli 49fc197e42 Bug2531 mitigation: Reduce the pause without progress dialog...
... Do so by lowering the usage of TransactionScope into UndoManager, so that
deletion of blocks is more often grouped into a transaction, as when invoking
Compact via the menu item.
2020-09-05 15:45:08 -04: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 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
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
Paul Licameli 4ca3e7096f
Track factory cleanup (#646)
* Don't need TrackFactory to make LabelTrack

* Don't need TrackFactory to make NoteTrack

* Don't need TrackFactory to make TimeTrack, or ZoomInfo in the factory

* Remove some forward declarations

* Rename TrackFactory as WaveTrackFactory, move it out of Track.cpp
2020-08-22 18:44:49 -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 e2d6e1cc24 AUP3: Update default/lastused path handling 2020-07-27 14:11:50 -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 a3fcd611b5
Dependency cleanup (#627)
* DBConnection doesn't use ProjectFileIO or need friendship...

... Instead, it is given its own weak_ptr to the project

* Demote the bypass flag into DBConnection...

... So SqliteSampleBlock needs ProjectFileIO only to get the DBConnection

* Accessor functions for the connection objects for SqliteSampleBlock

* Another level of indirection to get to the DBConnection object...

... The document holds the unique_ptr to DBConnection in an attached object;
later we want the SqliteSampleBlockFactory to locate the same pointer without
using ProjectFileIO

* SqliteSampleBlock and its factory don't use class ProjectFileIO...

... Instead they share a pointer to the pointer to the current DBConnection.

This means they no longer know how to invoke the lazy opening of that
connection.

So just require that this be done before any operations on blocks happen.  If
it hasn't, throw and let the application recover.

* ProjectFileIO no longer needs weak_ptr to Project for safety...

... so eliminate much ugliness from 127696879d

* Move DBConnection to new files...

... And SqliteSampleBlock does not depend on ProjectFileIO.

* SampleBlock.h doesn't need ClientData.h

* Function ProjectFileIO::Conn() isn't needed
2020-07-23 01:04:46 -05:00
Paul Licameli 061208c5cf Remove obsolete mentions of DirManager in comments 2020-07-20 19:03:40 -04:00
Leland Lucius 84f363ee07 AUP3: Simplify checkpoing and add checkpoint progress dialog
Also move the project file closure out of the ProjectFileIO
destructor and does it before the project file window is
destroyed.
2020-07-20 11:10:31 -05:00
Leland Lucius df4f3bd4e2 AUP3: "All supported files" filter missing AUP3 extension 2020-07-17 20:45:54 -05:00
Leland Lucius 93d9303c3d AUP3: Many corrections and (safe) speed ups
This reenables synchronous mode by default.  However, for processing
where a power cut or crash can be tolerated, synchronous and journaling
are disabled.  Once the processing is complete, they are reenabled.

Types of processing that are like this are "Save As", "Backup Project",
and "Vacuuming". They all write to a separate project file while
running, so the real project file is safe.

Unfortunately, effects are back to be slow and sluggish.

I believe I've address all of the weird file corruption issues and
I'll continue to continue testing for these.
2020-07-17 16:17:42 -05:00
Leland Lucius 5bc3ae659c AUP3: Added AUP3 importer and improved progress dialogs 2020-07-15 01:32:48 -05:00
Leland Lucius 0815344e5d AUP3: Reworked CopyTo() yet again
This time it has the potential to produce much smaller
output files since it ONLY copies the active blocks and
not all of the blocks related to undo history.  This is
done for "Save As" and "Backup Project".  Normal save
can't take advantage of this, but then it really doesn't
need it as it has to depend on vacuuming.

The vacuuming at close has been adjusted to utilize CopyTo()
so it should produce similarly small files as long as the
vacuuming happens when the project is definitely closing.
2020-07-13 00:04:54 -05:00
Leland Lucius b12fafbea0 AUP3: Fix stupied build failure 2020-07-10 01:32:56 -05:00
Paul Licameli 590d8c6d09
Fail safe save as (#606)
* ProjectFileIO::SaveProject() won't close original db until done...

... So on the failure path, don't risk closing the original too early, failing
with the new database, and then failing to reopen the original.

Just keep the original open and a new connection open too, until it is
certain that the initial population of the new database is successful.

* Check return value from AutoSaveDelete when saving-as

* Fix the remaining unchecked sqlite3_bind* calls, which are in Autosave...

...similarly to checks in 8b3f9fa

* When saving-as or -copy, open the new database only once

* Check return value from sqlite_initialize
2020-07-07 15:41:33 -05:00
Paul Licameli 7e85fc9f9f Clear the clipboard when the project from which it was copied closes. 2020-07-07 00:20:25 -04:00
Leland Lucius 48287e9b0d AUP3: Provides relief from slow shutdown
This is a hack to fix the long delay at Audacity shutdown
after editing large files and tossing the results (not
saving).
2020-07-02 22:08:39 -05:00
Paul Licameli 127696879d
Unitary changes (#599)
* Define SampleBlockFactory replacing static members of SampleBlock...

... This will become an abstract base class

* Sequence and WaveTrack only store SampleBlockFactory not Project...

... This adds a dependency from Track to SampleBlock which temporarily enlarges
a cycle in the dependency graph

* Register a global factory of SampleBlockFactory...

... so that later we can make an abstract SampleBlockFactory, separate from the
concrete implementation in terms of sqlite, and inject the dependency at startup
avoiding static dependency

* New concrete classes SqliteSampleBlock, SqliteSampleBlockFactory...

... separated from abstract base classes and put into a new source file,
breaking dependency cycles, and perhaps allowing easy reimplementation for other
databases in the future.

Note that the new file is a header-less plug-in!  Nothing depends on it.  It
uses static initialization to influence the program's behavior.

* Compile dependency on sqlite3.h limited to just two .cpp files...

... these are ProjectFileIO.cpp and SqliteSampleBlock.cpp.

But there is still close cooperation of ProjectFileIO and SqliteSampleBlock.cpp.
This suggests that these files ought to be merged, and perhaps ProjectFileIO
also needs to be split into abstract and concrete classes, and there should be
another injection of a factory function at startup.  That will make the choice
of database implementation even more modular.

Also removed one unnecessary inclusion of ProjectFileIO.h

* Fix crashes cutting and pasting cross-project...

... in case the source project is closed before the paste happens.

This caused destruction of the ProjectFileIO object and a closing of the sqlite
database with the sample data in it, leaving dangling references in the
SqliteSampleBlock objects.

The fix is that the SqliteSampleBlockFactory object holds a shared_ptr to the
ProjectFileIO object.  So the clipboard may own WaveTracks, which own WaveClips,
which own Sequences, which own SqliteSampleBlockFactories, which keep the
ProjectFileIO and the database connection alive until the clipboard is cleared.

The consequence of the fix is delayed closing of the entire database associated
with the source project.

If the source project is reopened before the clipboard is cleared, will there
be correct concurrent access to the same persistent store?  My preliminary
trials suggest this is so (reopening a saved project, deleting from it, closing
it again -- the clipboard contents are still unchanged and available).
2020-07-02 18:11:38 -05:00
Leland Lucius d39590cf41 AUP3: First round of updates
!!! THERE WILL NO DOUBT BE BUGS !!!

This is a big one and there's still several things to
complete. Just want to get this in the wild to start
receiving feedback.

One big thing right now is that it will NOT load pre-aup3
files.  An importer is on the way for that.
2020-07-01 02:30:18 -05:00
Leland Lucius cbf1bb558e AUP3: Removes OD code related to project file handling
This removes all of the OnDemand code embedded throughout
    the main codebase. Individual files related specifically
    to OD have been left in place, but removed from the build.
2020-07-01 01:14:05 -05:00
Paul Licameli a085057b66 Delay creation of tool docks and bars...
... after construction time for ToolManager, so that ToolManager can be
constructed earlier than ProjectWindow, and therefore the unspecified sequence
of invocation of factories of attached objects in the project won't lead to a
crash on any platform
2020-06-08 15:37:12 -04:00
Leland Lucius 7b9040c7e2 Rename TimerToolBar to TimeToolBar 2020-05-30 16:00:24 -05:00
Paul Licameli f8a070dde7 Rename macro wxPLURAL as XP (brief, and eliminates mention of "wx") 2020-05-22 12:48:49 -04:00
Paul Licameli 61abb87a77 Reviewed all i18n-hint comments...
... Moved many misplaced ones, which msgfmt would not have extracted into
audacity.pot.

Duplicated some of them, to appear with related but distinct msgids.

Added a few new comments.

Deleted one that was no longer needed in ProjectManager.cpp.
2020-04-05 09:00:00 -04:00
James Crook c60ec1a6e1 Bug 2235 - Timer Record does not shut down Computer if Automatic Save Project is not selected 2020-03-06 20:16:43 +00:00
James Crook 9985b8a9b8 Fix Big Time TimerToolBar, Stage III
Fixed issue where format selector could disappear.
Fixed upgrade from 2.3.3.
Remembers time format.
2020-02-14 12:02:21 +00:00
Paul Licameli c64b3cb31f Rewrite FileDialogWrapper using FileNames::FileTypes...
... also removing some repeated code and using the config keys /DefaultOpenType
and /LastOpenType only in Import.cpp
2019-12-29 15:35:03 -05:00
Paul Licameli 61161a2f00 TranslatableString for more status bar messages 2019-12-28 23:49:18 -05:00
Paul Licameli 1887928fe2 ProjectManager::GetHoursMinsString returns TranslatableString 2019-12-28 23:49:18 -05:00