1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-17 00:20:06 +02:00

🐛 Fixes

This commit is contained in:
Cookie Engineer 2021-07-04 16:52:33 +02:00
parent 2a37cd19a0
commit d9f30b2b72
No known key found for this signature in database
GPG Key ID: 340F6A4848C5F849
4 changed files with 1 additions and 128 deletions

View File

@ -22,7 +22,6 @@ Paul Licameli -- split from ProjectFileIO.cpp
#include "Project.h"
#include "FileException.h"
#include "wxFileNameWrapper.h"
#include "SentryHelper.h"
// Configuration to provide "safe" connections
static const char *SafeConfig =
@ -165,9 +164,6 @@ int DBConnection::OpenStepByStep(const FilePath fileName)
int rc = sqlite3_open(name, &mDB);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "DBConnection::OpenStepByStep::open");
wxLogMessage("Failed to open primary connection to %s: %d, %s\n",
fileName,
rc,
@ -187,9 +183,6 @@ int DBConnection::OpenStepByStep(const FilePath fileName)
rc = sqlite3_open(name, &mCheckpointDB);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "DBConnection::OpenStepByStep::open_checkpoint");
wxLogMessage("Failed to open checkpoint connection to %s: %d, %s\n",
fileName,
rc,
@ -293,9 +286,6 @@ bool DBConnection::Close()
rc = sqlite3_close(mCheckpointDB);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "DBConnection::Close::close_checkpoint");
wxLogMessage("Failed to close checkpoint connection for %s\n"
"\tError: %s\n",
sqlite3_db_filename(mCheckpointDB, nullptr),
@ -307,9 +297,6 @@ bool DBConnection::Close()
rc = sqlite3_close(mDB);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "DBConnection::OpenStepByStep::close");
wxLogMessage("Failed to close %s\n"
"\tError: %s\n",
sqlite3_db_filename(mDB, nullptr),
@ -357,10 +344,6 @@ int DBConnection::ModeConfig(sqlite3 *db, const char *schema, const char *config
rc = sqlite3_exec(db, sql, nullptr, nullptr, nullptr);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "DBConnection::ModeConfig");
ADD_EXCEPTION_CONTEXT("sqlite3.mode", config);
// Don't store in connection, just report it
wxLogMessage("Failed to set mode on %s\n"
"\tError: %s\n"
@ -412,10 +395,6 @@ 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)
{
ADD_EXCEPTION_CONTEXT("sqlite3.query", sql);
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "DBConnection::Prepare");
wxLogMessage("Failed to prepare statement for %s\n"
"\tError: %s\n"
"\tSQL: %s",
@ -489,9 +468,6 @@ void DBConnection::CheckpointThread(sqlite3 *db, const FilePath &fileName)
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "DBConnection::CheckpointThread");
wxLogMessage("Failed to perform checkpoint on %s\n"
"\tErrCode: %d\n"
"\tErrMsg: %s",
@ -564,9 +540,6 @@ bool TransactionScope::TransactionStart(const wxString &name)
if (errmsg)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "TransactionScope::TransactionStart");
mConnection.SetDBError(
XO("Failed to create savepoint:\n\n%s").Format(name)
);
@ -588,9 +561,6 @@ bool TransactionScope::TransactionCommit(const wxString &name)
if (errmsg)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "TransactionScope::TransactionCommit");
mConnection.SetDBError(
XO("Failed to release savepoint:\n\n%s").Format(name)
);
@ -612,9 +582,6 @@ bool TransactionScope::TransactionRollback(const wxString &name)
if (errmsg)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "TransactionScope::TransactionRollback");
mConnection.SetDBError(
XO("Failed to release savepoint:\n\n%s").Format(name)
);

View File

@ -36,7 +36,6 @@ Paul Licameli split from AudacityProject.cpp
#include "widgets/ProgressDialog.h"
#include "wxFileNameWrapper.h"
#include "xml/XMLFileReader.h"
#include "SentryHelper.h"
// Don't change this unless the file format changes
// in an irrevocable way
@ -513,9 +512,6 @@ int ProjectFileIO::Exec(const char *query, const ExecCB &callback)
if (rc != SQLITE_ABORT && errmsg)
{
ADD_EXCEPTION_CONTEXT("sqlite3.query", query);
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
SetDBError(
XO("Failed to execute a project file command:\n\n%s").Format(query),
Verbatim(errmsg),
@ -576,10 +572,6 @@ bool ProjectFileIO::GetBlob(const char *sql, wxMemoryBuffer &buffer)
rc = sqlite3_prepare_v2(db, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.query", sql);
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "ProjectGileIO::GetBlob::prepare");
SetDBError(
XO("Unable to prepare project file command:\n\n%s").Format(sql)
);
@ -596,10 +588,6 @@ bool ProjectFileIO::GetBlob(const char *sql, wxMemoryBuffer &buffer)
if (rc != SQLITE_ROW)
{
ADD_EXCEPTION_CONTEXT("sqlite3.query", sql);
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "ProjectGileIO::GetBlob::step");
SetDBError(
XO("Failed to retrieve data from the project file.\nThe following command failed:\n\n%s").Format(sql)
);
@ -742,9 +730,6 @@ bool ProjectFileIO::DeleteBlocks(const BlockIDs &blockids, bool complement)
rc = sqlite3_create_function(db, "inset", 1, SQLITE_UTF8 | SQLITE_DETERMINISTIC, const_cast<void*>(p), InSet, nullptr, nullptr);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "ProjectGileIO::DeleteBlocks::create_function");
/* i18n-hint: An error message. Don't translate inset or blockids.*/
SetDBError(XO("Unable to add 'inset' function (can't verify blockids)"));
return false;
@ -759,10 +744,6 @@ bool ProjectFileIO::DeleteBlocks(const BlockIDs &blockids, bool complement)
rc = sqlite3_exec(db, sql, nullptr, nullptr, nullptr);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.query", sql.ToStdString());
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "ProjectGileIO::GetBlob");
if( rc==SQLITE_READONLY)
/* i18n-hint: An error message. Don't translate blockfiles.*/
SetDBError(XO("Project is read only\n(Unable to work with the blockfiles)"));
@ -872,10 +853,6 @@ bool ProjectFileIO::CopyTo(const FilePath &destpath,
// Only capture the error if there wasn't a previous error
if (result != SQLITE_OK && (rc == SQLITE_DONE || rc == SQLITE_OK))
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT(
"sqlite3.context", "ProjectGileIO::CopyTo.cleanup");
SetDBError(
XO("Failed to rollback transaction during import")
);
@ -949,10 +926,6 @@ bool ProjectFileIO::CopyTo(const FilePath &destpath,
nullptr);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT(
"sqlite3.context", "ProjectGileIO::CopyTo.prepare");
SetDBError(
XO("Unable to prepare project file command:\n\n%s").Format(sql)
);
@ -983,10 +956,6 @@ bool ProjectFileIO::CopyTo(const FilePath &destpath,
rc = sqlite3_bind_int64(stmt, 1, blockid);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT(
"sqlite3.context", "ProjectGileIO::CopyTo.bind");
SetDBError(
XO("Failed to bind SQL parameter")
);
@ -998,10 +967,6 @@ bool ProjectFileIO::CopyTo(const FilePath &destpath,
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT(
"sqlite3.context", "ProjectGileIO::CopyTo.step");
SetDBError(
XO("Failed to update the project file.\nThe following command failed:\n\n%s").Format(sql)
);
@ -1011,10 +976,6 @@ bool ProjectFileIO::CopyTo(const FilePath &destpath,
// Reset statement to beginning
if (sqlite3_reset(stmt) != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT(
"sqlite3.context", "ProjectGileIO::CopyTo.reset");
THROW_INCONSISTENCY_EXCEPTION;
}
@ -1045,9 +1006,6 @@ bool ProjectFileIO::CopyTo(const FilePath &destpath,
rc = sqlite3_exec(db, "DETACH DATABASE outbound;", nullptr, nullptr, nullptr);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "ProjectGileIO::CopyTo::detach");
SetDBError(
XO("Destination project could not be detached")
);
@ -1772,9 +1730,6 @@ bool ProjectFileIO::AutoSaveDelete(sqlite3 *db /* = nullptr */)
rc = sqlite3_exec(db, "DELETE FROM autosave;", nullptr, nullptr, nullptr);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "ProjectGileIO::AutoSaveDelete");
SetDBError(
XO("Failed to remove the autosave information from the project file.")
);
@ -1815,10 +1770,6 @@ bool ProjectFileIO::WriteDoc(const char *table,
rc = sqlite3_prepare_v2(db, sql, -1, &stmt, nullptr);
if (rc != SQLITE_OK)
{
ADD_EXCEPTION_CONTEXT("sqlite3.query", sql);
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "ProjectGileIO::WriteDoc::prepare");
SetDBError(
XO("Unable to prepare project file command:\n\n%s").Format(sql)
);
@ -1834,10 +1785,6 @@ bool ProjectFileIO::WriteDoc(const char *table,
if (sqlite3_bind_blob(stmt, 1, dict.GetData(), dict.GetDataLen(), SQLITE_STATIC) ||
sqlite3_bind_blob(stmt, 2, data.GetData(), data.GetDataLen(), SQLITE_STATIC))
{
ADD_EXCEPTION_CONTEXT("sqlite3.query", sql);
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "ProjectGileIO::WriteDoc::bind");
SetDBError(
XO("Unable to bind to blob")
);
@ -1847,10 +1794,6 @@ bool ProjectFileIO::WriteDoc(const char *table,
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE)
{
ADD_EXCEPTION_CONTEXT("sqlite3.query", sql);
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "ProjectGileIO::WriteDoc::step");
SetDBError(
XO("Failed to update the project file.\nThe following command failed:\n\n%s").Format(sql)
);
@ -2452,9 +2395,6 @@ int64_t ProjectFileIO::GetDiskUsage(DBConnection &conn, SampleBlockID blockid /*
"SELECT rootpage FROM sqlite_master WHERE tbl_name = 'sampleblocks';");
if (stmt == nullptr || sqlite3_step(stmt) != SQLITE_ROW)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(sqlite3_errcode(conn.DB())));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "ProjectGileIO::GetDiskUsage");
return 0;
}

View File

@ -18,7 +18,6 @@ Paul Licameli -- split from SampleBlock.cpp and SampleBlock.h
#include "SampleBlock.h" // to inherit
#include "SentryHelper.h"
class SqliteSampleBlockFactory;
@ -559,10 +558,6 @@ size_t SqliteSampleBlock::GetBlob(void *dest,
// preconditions; should return SQL_OK which is 0
if (sqlite3_bind_int64(stmt, 1, mBlockID))
{
ADD_EXCEPTION_CONTEXT(
"sqlite3.rc", std::to_string(sqlite3_errcode(Conn()->DB())));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::GetBlob::bind");
wxASSERT_MSG(false, wxT("Binding failed...bug!!!"));
}
@ -570,9 +565,6 @@ size_t SqliteSampleBlock::GetBlob(void *dest,
rc = sqlite3_step(stmt);
if (rc != SQLITE_ROW)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::GetBlob::step");
wxLogDebug(wxT("SqliteSampleBlock::GetBlob - SQLITE error %s"), sqlite3_errmsg(db));
// Clear statement bindings and rewind statement
@ -684,10 +676,6 @@ void SqliteSampleBlock::Load(SampleBlockID sbid)
// preconditions; should return SQL_OK which is 0
if (sqlite3_bind_int64(stmt, 1, sbid))
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(sqlite3_errcode(Conn()->DB())));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Load::bind");
wxASSERT_MSG(false, wxT("Binding failed...bug!!!"));
}
@ -695,11 +683,6 @@ void SqliteSampleBlock::Load(SampleBlockID sbid)
rc = sqlite3_step(stmt);
if (rc != SQLITE_ROW)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Load::step");
wxLogDebug(wxT("SqliteSampleBlock::Load - SQLITE error %s"), sqlite3_errmsg(db));
// Clear statement bindings and rewind statement
@ -752,12 +735,6 @@ void SqliteSampleBlock::Commit(Sizes sizes)
sqlite3_bind_blob(stmt, 6, mSummary64k.get(), mSummary64kBytes, SQLITE_STATIC) ||
sqlite3_bind_blob(stmt, 7, mSamples.get(), mSampleBytes, SQLITE_STATIC))
{
ADD_EXCEPTION_CONTEXT(
"sqlite3.rc", std::to_string(sqlite3_errcode(Conn()->DB())));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Commit::bind");
wxASSERT_MSG(false, wxT("Binding failed...bug!!!"));
}
@ -765,9 +742,6 @@ void SqliteSampleBlock::Commit(Sizes sizes)
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Commit::step");
wxLogDebug(wxT("SqliteSampleBlock::Commit - SQLITE error %s"), sqlite3_errmsg(db));
// Clear statement bindings and rewind statement
@ -810,10 +784,6 @@ void SqliteSampleBlock::Delete()
// preconditions; should return SQL_OK which is 0
if (sqlite3_bind_int64(stmt, 1, mBlockID))
{
ADD_EXCEPTION_CONTEXT(
"sqlite3.rc", std::to_string(sqlite3_errcode(Conn()->DB())));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Delete::bind");
wxASSERT_MSG(false, wxT("Binding failed...bug!!!"));
}
@ -821,9 +791,6 @@ void SqliteSampleBlock::Delete()
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE)
{
ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Delete::step");
wxLogDebug(wxT("SqliteSampleBlock::Load - SQLITE error %s"), sqlite3_errmsg(db));
// Clear statement bindings and rewind statement

View File

@ -530,7 +530,6 @@ BaseItemSharedPtr HelpMenu()
#endif
Command( wxT("Log"), XXO("Show &Log..."), FN(OnShowLog),
AlwaysEnabledFlag ),
#endif
#ifdef IS_ALPHA
,