* Need only CloseLock now, not old Lock and Unlock...
... which were for cross-project cut and paste, but they no longer work and we
need another solution. So delete much old code.
* Fix dangling reference to AudacityProject completely! ...
... in SqliteSampleBlockFactory: retain ONLY the shared pointer to
ProjectFileIO, then pass that, not project, to constructors of blocks.
completing the work of 127696879d
* Restore part of the Bug2436 fix...
... which needs the non-default arguments to WaveTrack::EmptyCopy that got lost
at d39590cf41
So that pasted WaveTracks refer to the correct SampleBlockFactory and database
for their project
But this is not yet a sufficient re-fix for the bug
* Complete the fix for cross-project copies and 2436...
... by duplicating sample blocks, in Sequence.cpp, when it is wrong just to
share them.
And to determine which case it is, see whether source and destination Sequences
have the same sample block factories when doing Copy or Paste. Duplicate
when the factories are different. Otherwise sharing is safe and more space
efficient.
This does the analogous to what DirManager::CopyBlockFile did before commit
d39590c.
* Null checks on return from std::make_shared are unnecessary...
... instead std::bad_alloc would be thrown in case of memory exhaustion, which
we don't try to recover from.
* Restore uses of the mayThrow arguments in Sequence...
... that became unused at commit d39590cf41.
It's important to ignore exceptions from SampleBlocks when only displaying, not
editing or playing, and just treat missing data as silence.
Pass the boolean into the SampleBlock routines. But the throwing of exceptions
is not yet implemented.
* SampleBlockFactory functions guaranteed to return non-null or throw...
... which corrects Sequence.cpp, which was assuming non-null results.
This supplies the throw statements that the previous commit comment says were
still lacking.
This corrects the absence of checks of returns from sql_bind_... function calls
in SqliteSampleBlock.cpp. (Other calls remain to be checked elsewhere.)
User visible error messages, carried by the exceptions, might be improved.
* Restore the try/catch in AutoSaveFile::Decode...
... which was introduced at 2ba17c78d6
but removed at d39590cf41, yet without removing
the throw statement
which left the program vulnerable to abrupt termination instead of graceful
failure, when uninterpretable auto save contents are detected.
* 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).
* Eliminate unneeded back-pointer to project from non-wave Tracks...
... now that DirManager is gone
* Remove unused declarations
* SampleData::mProject was not used
* Correct ProjectFileIO::GetLibraryError
* Remove unnecessary #include directives
!!! 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.
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.
... To append files during recording or import, it doesn't depend on the
subclasses of BlockFile, instead taking a factory function to which it gives
the filename; and the choice of factory function is also lifted up through the
level of class Sequence which is just above DirManager.
This frees four files from dependency cycles, including DirManager.cpp but not
yet Sequence.cpp
... Unnecessary because transitively included.
But each .cpp file still includes its own .h file near the top to ensure
that it compiles indenendently, even if it is reincluded transitively later.
... for wxString and wxArrayStringEx, holding file paths (absolute or relative,
directory or plain file); to be replaced later with different types
(not yet using std::vector, becase of some uses of wxArrayString::Index with
two arguments)
... which will make it easier to change the types of those containers to
std::vectors of other string-like classes
for wxString,
IsEmpty => empty
Clear => clear
Alloc => reserve
for wxArrayString,
Count => size
GetCount => size
IsEmpty => empty
Add => push_back
Clear => clear
Empty => clear
Sort => std::sort (only with default comparator)
SetCount => resize
Last => back
Item => operator []
Alloc => reserve
... Assuming that large unsigned magnitudes with high order bit set are not
the problem, but signed negatives of small magnitude may be:
1) Always cast the unsigned to signed in comparisons, not the other way.
Also:
2) Cast unsigned TERM to signed by itself, before subtracting. Don't cast
the result.
3) Rewrite some comparisons by moving subtracted term to other side.
See commits
d2fe7b1757f463eda36c
... and similar wx "variadics," which all treat wxString smartly enough that
you don't need this.
Don't need c_str either to convert wxString to const wxChar * because
wxString has a conversion operator that does the same.
- Dead code from experiments in SelectionBar removed.
- Many warnings about unused parameters fixed with WXUNUSED()
- Many warnings about signed / unsigned comparisons cleaned up.
- Several 'local variable declared but not used' warnings fixed.
... Such projects as described in
http://forum.audacityteam.org/viewtopic.php?f=47&t=97787
(That thread did not describe the crashes, but I came across them, debugging,
or deduced the possibility of them)
In which all the shared_ptrs to BlockFile objects ended up pointing at one
common file; but the size of this file was sometimes larger than the
Sequence's maximum block size, or not the same as the difference between one
block's start offset and the next one's.
... That for SetSamples was too strict, making needless errors in case of
harmless zero-length clips.
The one for Get was analogous to SetSamples.
That for Delete was too lax. But reexamination shows the stricter condition
to be satisfied in all calls. Sequence::Delete() can be reached only from
WaveClip::Clear and WaveClip::ClearAndAddCutLine(), and all calls to those
are in WaveTrack.cpp.
... There are two in AboutDialog.cpp, but these strings aren't actually used.
There are two in InconsistencyException.cpp, which ought never to be seen by
users, but should be treated as high priority bugs if they are.
There is a very old one in Sequence.cpp, which was never internationalized and
was only written to the log and likewise ought to be eliminated from happening
in pre-release testing.
Therefore, though this is a minor breach of string freeze, it's only the second
one above that users might ever see, and then only if a serious bug escaped.
... I didn't figure out why reproducibility seemed to vary after startup
or on Linux or in Release build, but I am satisfied a real mistake is fixed
here.