1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-26 00:58:37 +02:00

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).
This commit is contained in:
Leland Lucius 2020-07-02 22:08:39 -05:00
parent 127696879d
commit 48287e9b0d
4 changed files with 61 additions and 28 deletions

View File

@ -87,13 +87,12 @@ static const char *ProjectFileSchema =
");" ");"
"" ""
// CREATE SQL sampleblocks // CREATE SQL sampleblocks
// 'samples' are fixed size blocks of float32 numbers. // 'samples' are fixed size blocks of int16, int32 or float32 numbers.
// The blocks may be partially empty. // The blocks may be partially empty.
// The quantity of valid data in the blocks is // The quantity of valid data in the blocks is
// provided in the project XML. // provided in the project XML.
// //
// sampleformat was once used to specify whether floats // sampleformat specifies the format of the samples stored.
// or ints for the data, but is no longer used.
// //
// blockID is a 64 bit number. // blockID is a 64 bit number.
// //
@ -198,6 +197,8 @@ ProjectFileIO::ProjectFileIO(AudacityProject &)
mModified = false; mModified = false;
mTemporary = true; mTemporary = true;
mBypass = false;
UpdatePrefs(); UpdatePrefs();
} }
@ -1289,3 +1290,14 @@ void ProjectFileIO::SetDBError(const TranslatableString & msg)
mLibraryError = Verbatim(sqlite3_errmsg(mDB)); mLibraryError = Verbatim(sqlite3_errmsg(mDB));
} }
} }
void ProjectFileIO::Bypass(bool bypass)
{
mBypass = bypass;
}
bool ProjectFileIO::ShouldBypass()
{
return mBypass;
}

View File

@ -19,6 +19,7 @@ Paul Licameli split from AudacityProject.h
struct sqlite3; struct sqlite3;
class AudacityProject; class AudacityProject;
class AutoCommitTransaction;
class AutoSaveFile; class AutoSaveFile;
class SqliteSampleBlock; class SqliteSampleBlock;
class WaveTrack; class WaveTrack;
@ -46,8 +47,6 @@ public:
ProjectFileIO &operator=( const ProjectFileIO & ) PROHIBITED; ProjectFileIO &operator=( const ProjectFileIO & ) PROHIBITED;
~ProjectFileIO(); ~ProjectFileIO();
bool WarnOfLegacyFile( );
// It seems odd to put this method in this class, but the results do depend // It seems odd to put this method in this class, but the results do depend
// on what is discovered while opening the file, such as whether it is a // on what is discovered while opening the file, such as whether it is a
// recovery file // recovery file
@ -79,6 +78,21 @@ public:
const TranslatableString &GetLastError() const; const TranslatableString &GetLastError() const;
const TranslatableString &GetLibraryError() const; const TranslatableString &GetLibraryError() const;
// Provides a means to bypass "DELETE"s at shutdown if the database
// is just going to be deleted anyway. This prevents a noticable
// delay caused by SampleBlocks being deleted when the Sequences that
// own them are deleted.
//
// This is definitely hackage territory. While this ability would
// still be needed, I think handling it in a DB abstraction might be
// a tad bit cleaner.
//
// For it's usage, see:
// SqliteSampleBlock::~SqliteSampleBlock()
// ProjectManager::OnCloseWindow()
void Bypass(bool bypass);
bool ShouldBypass();
private: private:
// XMLTagHandler callback methods // XMLTagHandler callback methods
bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override; bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override;
@ -128,6 +142,9 @@ private:
// Is this project still a temporary/unsaved project // Is this project still a temporary/unsaved project
bool mTemporary; bool mTemporary;
// Bypass transactions if database will be deleted after close
bool mBypass;
sqlite3 *mDB; sqlite3 *mDB;
FilePath mDBPath; FilePath mDBPath;
TranslatableString mLastError; TranslatableString mLastError;

View File

@ -672,6 +672,9 @@ void ProjectManager::OnCloseWindow(wxCloseEvent & event)
} }
} }
// See ProjectFileIO::Bypass() for a description
projectFileIO.Bypass(true);
#ifdef __WXMAC__ #ifdef __WXMAC__
// Fix bug apparently introduced into 2.1.2 because of wxWidgets 3: // Fix bug apparently introduced into 2.1.2 because of wxWidgets 3:
// closing a project that was made full-screen (as by clicking the green dot // closing a project that was made full-screen (as by clicking the green dot

View File

@ -283,7 +283,8 @@ SqliteSampleBlock::SqliteSampleBlock(AudacityProject *project)
SqliteSampleBlock::~SqliteSampleBlock() SqliteSampleBlock::~SqliteSampleBlock()
{ {
if (mRefCnt == 0) // See ProjectFileIO::Bypass() for a description of mIO.mBypass
if (mRefCnt == 0 && !mIO.ShouldBypass())
{ {
Delete(); Delete();
} }