1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 15:49:41 +02:00
This commit is contained in:
Roger Dannenberg 2021-03-27 17:01:12 -04:00
commit 78235c9a0e
4 changed files with 48 additions and 28 deletions

View File

@ -65,6 +65,10 @@ bool DBConnection::ShouldBypass()
void DBConnection::SetError(
const TranslatableString &msg, const TranslatableString &libraryError)
{
wxLogMessage(wxT("Connection msg: %s"), msg.Debug());
if (!libraryError.empty())
wxLogMessage(wxT("Connection error: %s"), libraryError.Debug());
mpErrors->mLastError = msg;
mpErrors->mLibraryError = libraryError;
}
@ -73,12 +77,12 @@ void DBConnection::SetDBError(
const TranslatableString &msg, const TranslatableString &libraryError)
{
mpErrors->mLastError = msg;
wxLogDebug(wxT("SQLite error: %s"), mpErrors->mLastError.Debug());
printf(" Lib error: %s", mpErrors->mLastError.Debug().mb_str().data());
wxLogMessage(wxT("SQLite error: %s"), mpErrors->mLastError.Debug());
printf("SQLite error: %s", mpErrors->mLastError.Debug().mb_str().data());
mpErrors->mLibraryError = libraryError.empty()
? Verbatim(sqlite3_errmsg(DB())) : libraryError;
wxLogDebug(wxT(" Lib error: %s"), mpErrors->mLibraryError.Debug());
wxLogMessage(wxT(" Lib error: %s"), mpErrors->mLibraryError.Debug());
printf(" Lib error: %s", mpErrors->mLibraryError.Debug().mb_str().data());
}
@ -271,7 +275,7 @@ sqlite3_stmt *DBConnection::Prepare(enum StatementID id, const char *sql)
rc = sqlite3_prepare_v3(mDB, sql, -1, SQLITE_PREPARE_PERSISTENT, &stmt, 0);
if (rc != SQLITE_OK)
{
wxLogDebug("prepare error %s", sqlite3_errmsg(mDB));
wxLogMessage("prepare error %s", sqlite3_errmsg(mDB));
THROW_INCONSISTENCY_EXCEPTION;
}

View File

@ -166,10 +166,13 @@ public:
{
// Enable URI filenames for all connections
mRc = sqlite3_config(SQLITE_CONFIG_URI, 1);
if (mRc == SQLITE_OK)
{
mRc = sqlite3_initialize();
mRc = sqlite3_config(SQLITE_CONFIG_LOG, LogCallback, nullptr);
if (mRc == SQLITE_OK)
{
mRc = sqlite3_initialize();
}
}
#ifdef NO_SHM
@ -193,6 +196,12 @@ public:
// It returns a value, but there's nothing we can do with it
(void) sqlite3_shutdown();
}
static void LogCallback(void *WXUNUSED(arg), int code, const char *msg)
{
wxLogMessage("sqlite3 message: (%d) %s", code, msg);
}
int mRc;
};
@ -356,6 +365,9 @@ bool ProjectFileIO::OpenConnection(FilePath fileName /* = {} */)
mProject.shared_from_this(), mpErrors, [this]{ OnCheckpointFailure(); } );
if (!curConn->Open(fileName))
{
SetDBError(
XO("Failed to open database file:\n\n%s").Format(fileName)
);
curConn.reset();
return false;
}
@ -692,43 +704,44 @@ bool ProjectFileIO::DeleteBlocks(const BlockIDs &blockids, bool complement)
if (rc != SQLITE_OK)
{
/* i18n-hint: An error message. Don't translate inset or blockids.*/
SetError(XO("Unable to add 'inset' function (can't verify blockids)"));
SetDBError(XO("Unable to add 'inset' function (can't verify blockids)"));
wxLogWarning(GetLastError().Translation());
return false;
}
// Delete all rows in the set, or not in it
// This is the first command that writes to the database, and so we
// do more informative error reporting than usual, if it fails.
auto sql = wxString::Format(
"DELETE FROM sampleblocks WHERE %sinset(blockid);",
complement ? "NOT " : "" );
rc = sqlite3_exec(db, sql, nullptr, nullptr, nullptr);
if (rc != SQLITE_OK)
{
// we give the string 'error' to get the default url for read project errors.
if( rc==SQLITE_READONLY)
/* i18n-hint: An error message. Don't translate orphan or blockfiles.*/
SetError(XO("Project is read only\n(can't clean orphan blockfiles)"), XO("error"));
/* i18n-hint: An error message. Don't translate blockfiles.*/
SetDBError(XO("Project is read only\n(Unable to work with the blockfiles)"));
else if( rc==SQLITE_LOCKED)
/* i18n-hint: An error message. Don't translate orphan or blockfiles.*/
SetError(XO("Project is locked\n(can't clean orphan blockfiles)"), XO("error"));
/* i18n-hint: An error message. Don't translate blockfiles.*/
SetDBError(XO("Project is locked\n(Unable to work with the blockfiles)"));
else if( rc==SQLITE_BUSY)
/* i18n-hint: An error message. Don't translate orphan or blockfiles.*/
SetError(XO("Project is busy\n(can't clean orphan blockfiles)"), XO("error"));
/* i18n-hint: An error message. Don't translate blockfiles.*/
SetDBError(XO("Project is busy\n(Unable to work with the blockfiles)"));
else if( rc==SQLITE_CORRUPT)
/* i18n-hint: An error message. Don't translate orphan or blockfiles.*/
SetError(XO("Project is corrupt\n(can't clean orphan blockfiles)"), XO("error"));
/* i18n-hint: An error message. Don't translate blockfiles.*/
SetDBError(XO("Project is corrupt\n(Unable to work with the blockfiles)"));
else if( rc==SQLITE_PERM)
/* i18n-hint: An error message. Don't translate orphan or blockfiles.*/
SetError(XO("Some permissions issue\n(can't clean orphan blockfiles)"), XO("error"));
/* i18n-hint: An error message. Don't translate blockfiles.*/
SetDBError(XO("Some permissions issue\n(Unable to work with the blockfiles)"));
else if( rc==SQLITE_IOERR)
/* i18n-hint: An error message. Don't translate orphan or blockfiles.*/
SetError(XO("A disk I/O error\n(can't clean orphan blockfiles)"), XO("error"));
/* i18n-hint: An error message. Don't translate blockfiles.*/
SetDBError(XO("A disk I/O error\n(Unable to work with the blockfiles)"));
else if( rc==SQLITE_AUTH)
/* i18n-hint: An error message. Don't translate orphan or blockfiles.*/
SetError(XO("Not authorized\n(can't clean orphan blockfiles)"), XO("error"));
/* i18n-hint: An error message. Don't translate blockfiles.*/
SetDBError(XO("Not authorized\n(Unable to work with the blockfiles)"));
else
/* i18n-hint: An error message. Don't translate orphan or blockfiles.*/
SetError(XO("Cleanup of orphan blocks failed"), XO("error"));
/* i18n-hint: An error message. Don't translate blockfiles.*/
SetDBError(XO("Unable to work with the blockfiles"));
wxLogWarning(GetLastError().Translation());
return false;
@ -1800,7 +1813,8 @@ bool ProjectFileIO::LoadProject(const FilePath &fileName, bool ignoreAutosave)
->GetActiveBlockIDs();
if (blockids.size() > 0)
{
if (!DeleteBlocks(blockids, true))
success = DeleteBlocks(blockids, true);
if (!success)
{
return false;
}
@ -1823,7 +1837,8 @@ bool ProjectFileIO::LoadProject(const FilePath &fileName, bool ignoreAutosave)
// we use that knowledge to determine if this file is an unsaved/temporary
// file or a permanent project file
wxString result;
if (!GetValue("SELECT Count(*) FROM project;", result))
success = GetValue("SELECT Count(*) FROM project;", result);
if (!success)
{
return false;
}

View File

@ -341,7 +341,7 @@ DBConnection *SqliteSampleBlock::Conn() const
if (!pConnection) {
throw SimpleMessageBoxException
{
XO("Failed to open the project's database"),
XO("Connection to project file is null"),
XO("Warning"),
"Error:_Disk_full_or_not_writable"
};

View File

@ -35,7 +35,8 @@ bool EffectTwoPassSimpleMono::Process()
const_cast<AudacityProject*>( FindProject() ) );
for (auto track : mOutputTracks->Selected< WaveTrack >()) {
mWorkTracks->Add(track->EmptyCopy())->ConvertToSampleFormat(floatSample);
mWorkTracks->back()->InsertSilence(0, mT0);
if( mT0 > 0 )
mWorkTracks->back()->InsertSilence(0, mT0);
}
mTrackLists[0] = &mOutputTracks;